Search in sources :

Example 41 with FileReader

use of java.io.FileReader in project CoreNLP by stanfordnlp.

the class TregexGUI method loadTsurgeonScript.

private void loadTsurgeonScript() {
    if (chooser == null)
        chooser = createFileChooser();
    int status = chooser.showOpenDialog(this);
    if (status == JFileChooser.APPROVE_OPTION) {
        Thread t = new Thread() {

            @Override
            public void run() {
                try {
                    BufferedReader reader = new BufferedReader(new FileReader(chooser.getSelectedFile().toString()));
                    final String tregexPatternString = Tsurgeon.getTregexPatternFromReader(reader);
                    final String tsurgeonOperationsString = Tsurgeon.getTsurgeonTextFromReader(reader);
                    SwingUtilities.invokeLater(() -> InputPanel.getInstance().setScriptAndPattern(tregexPatternString, tsurgeonOperationsString));
                } catch (IOException e) {
                    System.out.println("Error parsing Tsurgeon file");
                //e.printStackTrace();
                }
            }
        };
        t.start();
    }
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException)

Example 42 with FileReader

use of java.io.FileReader in project Cloud9 by lintool.

the class AFormatterWG method readStopList.

private static HashSet<Integer> readStopList(JobConf jc) {
    HashSet<Integer> out = new HashSet<Integer>();
    try {
        //System.out.println(">> " + DistributedCache.getLocalCacheFiles(jc).toString());
        Path[] cacheFiles = DistributedCache.getLocalCacheFiles(jc);
        //String[] cacheFiles;
        //cacheFiles = jc.getStrings("stoplist");
        FileReader fr = new FileReader(cacheFiles[0].toString());
        BufferedReader stopReader = new BufferedReader(fr);
        String line;
        while ((line = stopReader.readLine()) != null) {
            out.add(Integer.parseInt(line));
        }
        stopReader.close();
        return out;
    } catch (IOException ioe) {
        System.err.println("IOException reading from distributed cache");
        System.err.println(ioe.toString());
        return out;
    }
}
Also used : Path(org.apache.hadoop.fs.Path) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 43 with FileReader

use of java.io.FileReader in project Cloud9 by lintool.

the class HFormatterWG method readStopList.

private static HashSet<Integer> readStopList(JobConf jc) {
    HashSet<Integer> out = new HashSet<Integer>();
    try {
        //System.out.println(">> " + DistributedCache.getLocalCacheFiles(jc).toString());
        Path[] cacheFiles = DistributedCache.getLocalCacheFiles(jc);
        //String[] cacheFiles;
        //cacheFiles = jc.getStrings("stoplist");
        FileReader fr = new FileReader(cacheFiles[0].toString());
        BufferedReader stopReader = new BufferedReader(fr);
        String line;
        while ((line = stopReader.readLine()) != null) {
            out.add(Integer.parseInt(line));
        }
        stopReader.close();
        return out;
    } catch (IOException ioe) {
        System.err.println("IOException reading from distributed cache");
        System.err.println(ioe.toString());
        return out;
    }
}
Also used : Path(org.apache.hadoop.fs.Path) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 44 with FileReader

use of java.io.FileReader in project camel by apache.

the class FileHelper method loadFile.

/**
     * Loads the file
     */
public static List<String> loadFile(File file) throws Exception {
    List<String> lines = new ArrayList<>();
    LineNumberReader reader = new LineNumberReader(new FileReader(file));
    String line;
    do {
        line = reader.readLine();
        if (line != null) {
            lines.add(line);
        }
    } while (line != null);
    reader.close();
    return lines;
}
Also used : ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) LineNumberReader(java.io.LineNumberReader)

Example 45 with FileReader

use of java.io.FileReader in project databus by linkedin.

the class CheckpointSerializerMain method loadProperties.

private static Properties loadProperties(String fileName) throws IOException {
    Properties result = new Properties();
    FileReader freader = new FileReader(fileName);
    try {
        result.load(freader);
    } finally {
        freader.close();
    }
    return result;
}
Also used : FileReader(java.io.FileReader) Properties(java.util.Properties)

Aggregations

FileReader (java.io.FileReader)1873 BufferedReader (java.io.BufferedReader)1289 IOException (java.io.IOException)893 File (java.io.File)811 FileNotFoundException (java.io.FileNotFoundException)304 ArrayList (java.util.ArrayList)274 Test (org.junit.Test)197 FileWriter (java.io.FileWriter)148 HashMap (java.util.HashMap)116 Reader (java.io.Reader)99 BufferedWriter (java.io.BufferedWriter)98 Properties (java.util.Properties)66 InputStreamReader (java.io.InputStreamReader)64 LineNumberReader (java.io.LineNumberReader)61 Matcher (java.util.regex.Matcher)61 Map (java.util.Map)59 List (java.util.List)56 PrintWriter (java.io.PrintWriter)51 StringTokenizer (java.util.StringTokenizer)51 HashSet (java.util.HashSet)50