Example usage for java.io FileReader close

List of usage examples for java.io FileReader close

Introduction

In this page you can find the example usage for java.io FileReader close.

Prototype

public void close() throws IOException 

Source Link

Usage

From source file:Main.java

public static String readFileContent(File file) throws IOException {
    FileReader in = new FileReader(file);
    StringBuilder contents = new StringBuilder();
    char[] buffer = new char[4096];
    int read = 0;
    try {/* w  ww.  j av a 2  s  .co  m*/
        do {
            contents.append(buffer, 0, read);
            read = in.read(buffer);
        } while (read >= 0);
        return contents.toString();
    } finally {
        in.close();
    }
}

From source file:Main.java

public static String readFileContent(String filename) throws IOException {
    FileReader in = new FileReader(filename);
    StringBuilder contents = new StringBuilder();
    char[] buffer = new char[4096];
    int read = 0;
    try {/*w  w  w. ja v a2s.c o  m*/
        do {
            contents.append(buffer, 0, read);
            read = in.read(buffer);
        } while (read >= 0);
        return contents.toString();
    } finally {
        in.close();
    }
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<byte[]> getFileContentAsBytes(String f) throws IOException {
    FileReader fr = new FileReader(f);
    BufferedReader br = new BufferedReader(fr);
    List<byte[]> res = getFileContentAsBytes(br);
    fr.close();
    return res;//from  ww w.  j  av  a  2 s . c  o m
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<byte[]> getFileContentAsBytes(File f) throws IOException {
    FileReader fr = new FileReader(f);
    BufferedReader br = new BufferedReader(fr);
    List<byte[]> res = getFileContentAsBytes(br);
    fr.close();
    return res;//from ww  w . ja va 2s .c  o m
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<char[]> getFileContentAsChars(File f) throws IOException {
    FileReader fr = new FileReader(f);
    BufferedReader br = new BufferedReader(fr);
    List<char[]> res = getFileContentAsChars(br);
    fr.close();
    return res;//from  w w  w.  j a v a  2 s . com
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<char[]> getFileContentAsChars(String f) throws IOException {
    FileReader fr = new FileReader(f);
    BufferedReader br = new BufferedReader(fr);
    List<char[]> res = getFileContentAsChars(br);
    fr.close();
    return res;/*from  ww w  .j a  v  a 2s. com*/
}

From source file:Main.java

/** Retrieve list of media sources */
public static boolean ReadUrlInfoToList(List<String> listUrl, String configureFile) {
    String sUrl, line = "";
    sUrl = configureFile;/*from  www . j a  va2s.c o m*/
    File UrlFile = new File(sUrl);

    if (!UrlFile.exists())
        return false;

    FileReader fileread;

    try {
        fileread = new FileReader(UrlFile);
        BufferedReader bfr = new BufferedReader(fileread);
        try {
            while (line != null) {
                line = bfr.readLine();
                if (line != null)
                    listUrl.add(line);
            }

            fileread.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    return true;
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<String> getFileContentAsStrings(Path f) throws IOException {
    FileReader fr = new FileReader(f.toString());
    BufferedReader br = new BufferedReader(fr);
    List<String> res = getFileContentAsStrings(br);
    fr.close();
    return res;/*from  w  w  w . j  a v  a  2s.c  om*/
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<String> getFileContentAsStrings(File f) throws IOException {
    FileReader fr = new FileReader(f.toString());
    BufferedReader br = new BufferedReader(fr);
    List<String> res = getFileContentAsStrings(br);
    fr.close();
    return res;/*from  ww  w .java  2 s . com*/
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<String> getFileContentAsStrings(String f) throws IOException {
    FileReader fr = new FileReader(f.toString());
    BufferedReader br = new BufferedReader(fr);
    List<String> res = getFileContentAsStrings(br);
    fr.close();
    return res;//from w ww  . j  a  v a  2 s.co  m
}