Here you can find the source of loadUnicodeStringFromFile(final File file)
Parameter | Description |
---|---|
file | The file |
Parameter | Description |
---|---|
IOException | For any error |
public static String loadUnicodeStringFromFile(final File file) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { /**//from w w w. j av a 2 s .c o m * Load unicode string from file. * * @param file The file * @return The string read * @throws IOException For any error */ public static String loadUnicodeStringFromFile(final File file) throws IOException { StringBuffer content = new StringBuffer(); try (final BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(file), "UTF8"))) { final char[] buffer = new char[1 << (3 * 5)]; // 64k buf. int read; while ((read = br.read(buffer)) > 0) { content.append(buffer, 0, read); } } return content.toString(); } }