Java tutorial
//package com.java2s; import java.io.FileInputStream; public class Main { public static String readString(String file, String charset) { byte[] data = readBytes(file); String ret = null; try { ret = new String(data, charset); } catch (Exception e) { System.out.println(e.getMessage()); } return ret; } public static byte[] readBytes(String file) { try { FileInputStream fis = new FileInputStream(file); int len = fis.available(); byte[] buffer = new byte[len]; fis.read(buffer); fis.close(); return buffer; } catch (Exception e) { System.out.println(e.getMessage()); } return null; } }