public static String readFile(File file, String defaultEncoding) throws IOException {  FileInputStream in = new FileInputStream(file); byte[] chunk = new byte[512]; ByteArrayOutputStream out = new ByteArrayOutputStream(); int l; do { l = in.read(chunk); if (l > 0) out.write(chunk, 0, l);  } while (l > -1); in.close(); byte[] data = out.toByteArray(); String xmlDecl = getXMLDecl(data); String enc = getEncoding(xmlDecl); if (enc == null) enc = defaultEncoding;  try { return new String(out.toByteArray(), enc); } catch (UnsupportedEncodingException e) { return new String(out.toByteArray()); }
public final static String readFile(File file) throws IOException { return readFile(file, "ISO-8859-1");
	public static String readFile(File file, String defaultEncoding) throws IOException {		// read the file into a string		FileInputStream in = new FileInputStream(file);		byte[] chunk = new byte[512];		ByteArrayOutputStream out = new ByteArrayOutputStream();		int l;		do {			l = in.read(chunk);			if (l > 0)				out.write(chunk, 0, l);		} while (l > -1);		in.close();		byte[] data = out.toByteArray();		String xmlDecl = getXMLDecl(data);		String enc = getEncoding(xmlDecl);		if (enc == null)			enc = defaultEncoding;		try {			return new String(out.toByteArray(), enc);		} catch (UnsupportedEncodingException e) {			return new String(out.toByteArray());		}	}