Java BufferedReader Read loadUnicodeStringFromFile(final File file)

Here you can find the source of loadUnicodeStringFromFile(final File file)

Description

Load unicode string from file.

License

Open Source License

Parameter

Parameter Description
file The file

Exception

Parameter Description
IOException For any error

Return

The string read

Declaration

public static String loadUnicodeStringFromFile(final File file) throws IOException 

Method Source Code


//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();
    }
}

Related

  1. loadTrustDistrustSets(String trust_data_set)
  2. loadTrustSet(String trustSet)
  3. loadTwoColumnResource(InputStream resource)
  4. loadTxnDescriptions(String filename)
  5. loadTXTList(String listFile, int size)
  6. loadVocab(String vocabFilePath, double factor)
  7. loadWaypoints(File inFile)
  8. loadXML(String fileName)
  9. loadXMLDocumentFromClasspath(String resourcePath)