List of utility methods to do UTF8 File Read
String | loadUTF8(File file) load UTF FileInputStream is = new FileInputStream(file); try { byte[] buf = new byte[1024]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while (true) { int read = is.read(buf); if (read == -1) break; ... |
List | loadUTF8LinesFromFile(File file) load UTF Lines From File InputStream is = new FileInputStream(file); Scanner scanner = new Scanner(is, "UTF-8"); List<String> r = new ArrayList<String>(); while (scanner.hasNextLine()) r.add(scanner.nextLine()); is.close(); return r; |
String | readFile(String fileName, String encoding) read File try { File adfile = new File(fileName); StringBuffer content = new StringBuffer(); if (adfile.isFile() && adfile.exists()) { InputStreamReader read = new InputStreamReader( new FileInputStream(adfile), encoding); BufferedReader in = new BufferedReader(read); String line1; ... |
String | readFromFile(String fileName) reads the contents of the file passed in and returns the content as a String. StringBuilder sb = new StringBuilder(); FileInputStream fstream = new FileInputStream(fileName); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8")); String line; while ((line = br.readLine()) != null) { sb.append(line); ... |