All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.au.id.jericho.lib.html.Util Maven / Gradle / Ivy

Go to download

Jericho HTML Parser is a simple but powerful java library allowing analysis and manipulation of parts of an HTML document, including some common server-side tags, while reproducing verbatim any unrecognised or invalid HTML. It also provides high-level HTML form manipulation functions.

There is a newer version: 2.3
Show newest version
// Jericho HTML Parser - Java based library for analysing and manipulating HTML
// Version 1.5
// Copyright (C) 2004 Martin Jericho
// http://jerichohtml.sourceforge.net/
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// http://www.gnu.org/copyleft/lesser.html
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package au.id.jericho.lib.html;

import java.util.*;
import java.io.*;

/**
 * This class contains miscellaneous utility methods not directly associated with the HTML Parser library.
 */
public final class Util {
	private static final int BUFFER_SIZE=1024;
	private static final String CSVNewLine=System.getProperty("line.separator");

	private Util() {}

	public static String getString(Reader reader) throws IOException {
		if (reader==null) return null;
		BufferedReader in=new BufferedReader(reader,BUFFER_SIZE);
		int charsRead;
		char[] copyBuffer=new char[BUFFER_SIZE];
		StringBuffer sb=new StringBuffer();
		while ((charsRead=in.read(copyBuffer,0,BUFFER_SIZE))!=-1)
			sb.append(copyBuffer,0,charsRead);
		in.close();
		return sb.toString();
	}

  public static void outputCSVLine(Writer writer, String[] values) throws IOException {
  	for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy