Revision as of 04:10, 23 November 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
public static byte[] convertFileToByteArray(String filename) {
	java.io.File f = new java.io.File(filename);
	java.io.FileInputStream fis = null;
	byte[] stream = new byte[(int) f.length()];
	try {
		fis = new java.io.FileInputStream(f);
	} catch (java.io.FileNotFoundException ex) {
		Ts.printErr(ex);
	}
	try {
		fis.read(stream);
		fis.close();
	} catch (java.io.IOException ex) {
		Ts.printErr(ex);
	}
	return stream;
}
 
public static void printErr(java.lang.Exception ex) {
	printErr(ex.getMessage());
}


Back to JavaHowTo

Alumni Liaison

Recent Math PhD now doing a post-doctorate at UC Riverside.

Kuei-Nuan Lin