Package java.io

Examples of java.io.FileReader


    }

    public <T> T getData(Class<T> clazz, String str) throws Exception {
        JAXBContext context = JAXBContext.newInstance(clazz);
        Unmarshaller u = context.createUnmarshaller();
        return (T) u.unmarshal(new FileReader(new File(folder, str)));
    }
View Full Code Here


    XMLMemento memento = null;
    // TODO rebuild memento for whole plugin?
    try {
        File mementoFile = getWorkingSetMemento();
        if (mementoFile.exists()) {
            FileReader reader = new FileReader(mementoFile);
            memento = XMLMemento.createReadRoot(reader);
            if (memento != null) {
                _actionGroup.restoreState(memento);
            }
        }
View Full Code Here

        } // iterate through every line of the text file      
    }

    protected void readSettings() {
        try {
            FileReader propReader = new FileReader(new File(folder, propFile));
            prop.load(propReader);
        } catch (FileNotFoundException ex) {
            logger.info("File not found: " + propFile + " - Will apply default properties:" + prop);
        } catch (IOException ex) {
            logger.fatal("Couldn't load properties from " + propFile);
View Full Code Here

    protected void initReaders() {
        String fFile = prop.getProperty("tf.feature.file");
        try {
            if (featureReader == null)
                setFeatureReader(new FileReader(new File(folder, fFile)));
        } catch (FileNotFoundException ex) {
            logger.fatal("Couldn't find " + fFile);
        }

        String eFile = prop.getProperty("tf.event.file");
        try {
            if (eventReader == null)
                setEventReader(new FileReader(new File(folder, eFile)));
        } catch (FileNotFoundException ex) {
            logger.fatal("Couldn't find " + eFile);
        }

        String pFile = prop.getProperty("tf.person.file");
        try {
            if (personReader == null)
                setPersonReader(new FileReader(new File(folder, pFile)));
        } catch (FileNotFoundException ex) {
            logger.fatal("Couldn't find " + pFile);
        }

        String lFile = prop.getProperty("tf.location.file");
        try {
            if (locationReader == null)
                setLocationReader(new FileReader(new File(folder, lFile)));
        } catch (FileNotFoundException ex) {
            logger.fatal("Couldn't find " + lFile);
        }
    }
View Full Code Here

                            tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
                    if (resultOP != JOptionPane.OK_OPTION) {
                        return;
                    }
                }
                reader = new FileReader(file);
            }
        } catch (Exception ex) {
            String errorMsg = "Cannot read file! " + ex.getLocalizedMessage();
            logger.fatal(errorMsg, ex);
            bar.setErrorMessage(errorMsg);
View Full Code Here

        return writer.toString();
    }

    public static String getFromFile(File file, int blockSize)
            throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(file));
        char character[] = new char[blockSize];
        StringBuilder sb = new StringBuilder(character.length);
        int ret;
        while ((ret = reader.read(character)) != -1) {
            sb.append(character, 0, ret);
View Full Code Here

   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    //Reader fileReader = new InputStreamReader(MultiReader.class.getResourceAsStream("failing-case-20061108.txt"));
    Reader fileReader =  new FileReader("failing-case.txt");
    BufferedReader in = new BufferedReader(fileReader);
    int modelNumber = 0;
    PrintWriter currentOut = null;
    for (String line = in.readLine(); line != null; line = in.readLine()) {
      if (line.equals("<rdf:RDF")) {
View Full Code Here

     * @return
     * @throws IOException
     * @since 4.3
     */
    public static String loadHeader(String fileName) throws IOException {
        FileReader fr = null;
        BufferedReader br = null;
        try {
            fr = new FileReader(fileName);
            br = new BufferedReader(fr);
            String header = br.readLine();
            if (header != null && header.indexOf('#') == 0) {
                header = header.substring(1);
            }
            return header;
        } finally {
            if (br != null) {
                br.close();
            }
            if (fr != null) {
                fr.close();
            }
        }
    }
View Full Code Here

public class TestReaderInputStream {
 
  @Test public void testUTF8() throws Exception {
    FileInputStream fis = new FileInputStream(UnitTestUtil.getTestDataFile("legal_notice.xml")); //$NON-NLS-1$
    ReaderInputStream ris = new ReaderInputStream(new FileReader(UnitTestUtil.getTestDataFile("legal_notice.xml")), Charset.forName("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
   
    int value;
    while (true) {
      value = fis.read();
      assertEquals(value, ris.read());
View Full Code Here

        return new Object[][] { { "/experiment/zipfgen/zipf-S4000000-L1-R4000000-P10.dat", 64,
                131072 /* 1024 * 1024 / 8 */, 15625 /* 1000000 / 64 */, 20d, 100, 8 } };
    }

    private static long[][] readDistribution(File file, int nthreads, int round) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(file));
        long[][] dist = new long[nthreads][];
        for(int th = 0; th < nthreads; th++) {
            long[] curdist = new long[round];
            dist[th] = curdist;
            for(int i = 0; i < round; i++) {
View Full Code Here

TOP

Related Classes of java.io.FileReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.