Search in sources :

Example 71 with FileReader

use of java.io.FileReader in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoCoverageCalculationTest method parseData.

@NotNull
private GoCoverageProjectData parseData(@NotNull String coverageSource) throws IOException {
    try (BufferedReader reader = new BufferedReader(new FileReader(new File(getTestDataPath(), coverageSource)))) {
        GoCoverageProjectData data = GoCoverageRunner.parseCoverage(reader, myFixture.getProject(), myModule);
        assertNotNull(data);
        return data;
    }
}
Also used : GoCoverageProjectData(com.goide.runconfig.testing.coverage.GoCoverageProjectData) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 72 with FileReader

use of java.io.FileReader in project FBReaderJ by geometer.

the class ZLConfigWriterTests method writeConfigAndCheck.

private void writeConfigAndCheck(String fileName, String expectedContent) throws FileNotFoundException {
    if (fileName.equals("delta")) {
        ZLConfigManager.getInstance().saveDelta();
    } else {
        ZLConfigManager.getInstance().saveAll();
    }
    try {
        FileReader fr = new FileReader(new File("test/org/test/zlibrary/options/examples/output/" + fileName + ".xml"));
        try {
            int expectedContentSize = expectedContent.length();
            char[] buf = new char[expectedContentSize];
            fr.read(buf, 0, expectedContentSize);
            assertEquals(expectedContent, new String(buf));
        } finally {
            try {
                fr.close();
            } catch (IOException e) {
                fail("can't close reader");
            }
        }
    } catch (FileNotFoundException e) {
        throw e;
    } catch (IOException e) {
        fail("IOException : " + e.getMessage());
    } catch (IndexOutOfBoundsException e) {
        fail("content has length that's not equal expected content length ");
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File)

Example 73 with FileReader

use of java.io.FileReader in project gocd by gocd.

the class BuildOutputLogger method loadFile.

private List loadFile(int firstLine) {
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new FileReader(data));
        skipLines(reader, firstLine);
        return readUptoMaxLines(reader);
    } catch (IOException e) {
        return new ArrayList();
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) IOException(java.io.IOException)

Example 74 with FileReader

use of java.io.FileReader in project storm-hbase by ypf412.

the class HBaseTestUtil method loadStreamDataToHBase.

/**
	 * Load stream data to HBase table
	 * @param filePath
	 * @param hTable
	 * @param hbasePropConfig
	 */
public static void loadStreamDataToHBase(String filePath, HTable hTable, PropConfig hbasePropConfig) {
    final String CTRL_C = "";
    final String CTRL_E = "";
    List<Put> putList = new ArrayList<Put>();
    if (!filePath.startsWith("/")) {
        filePath = ClassLoader.getSystemResource(filePath).getFile();
    }
    try {
        FileReader fr = new FileReader(filePath);
        BufferedReader br = new BufferedReader(fr);
        try {
            String line = null;
            while ((line = br.readLine()) != null) {
                String[] kvs = line.split(CTRL_C);
                if (// must be two key-value parts
                kvs.length != 2)
                    continue;
                String key = kvs[0];
                String value = kvs[1];
                String[] keys = key.split(CTRL_E);
                if (// at least contains <shardingkey, timestamp>
                keys.length < 2)
                    continue;
                short sharding = Short.parseShort(keys[0]);
                int timestamp = Integer.parseInt(keys[1]);
                byte[] shardingKey = { (byte) sharding };
                byte[] timestampKey = Bytes.toBytes(timestamp);
                byte[] rowKey = Bytes.add(shardingKey, timestampKey);
                for (int i = 2; i < keys.length; i++) {
                    rowKey = Bytes.add(rowKey, Bytes.toBytes(keys[i]));
                }
                Put put = new Put(rowKey);
                byte[] columnFamily = Bytes.toBytes(Constants.HBASE_DEFAULT_COLUMN_FAMILY);
                String columnFamilyStr = hbasePropConfig.getProperty("hbase.table.column_family");
                if (columnFamilyStr != null && !columnFamilyStr.equals(""))
                    columnFamily = Bytes.toBytes(columnFamilyStr);
                byte[] column = Bytes.toBytes(Constants.HBASE_DEFAULT_COLUMN);
                String columnStr = hbasePropConfig.getProperty("hbase.table.column");
                if (columnStr != null && !columnStr.equals(""))
                    column = Bytes.toBytes(columnStr);
                put.add(columnFamily, column, Bytes.toBytes(value));
                putList.add(put);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
    }
    try {
        hTable.put(putList);
        hTable.flushCommits();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) Put(org.apache.hadoop.hbase.client.Put)

Example 75 with FileReader

use of java.io.FileReader in project XobotOS by xamarin.

the class GenerateGL method emit.

private static void emit(int version, boolean ext, boolean pack, CodeEmitter emitter, BufferedReader specReader, PrintStream glStream, PrintStream glImplStream, PrintStream cStream) throws Exception {
    String s = null;
    while ((s = specReader.readLine()) != null) {
        if (s.trim().startsWith("//")) {
            continue;
        }
        CFunc cfunc = CFunc.parseCFunc(s);
        String fname = cfunc.getName();
        File f = new File("stubs/jsr239/" + fname + ".java-1" + version + "-if");
        if (f.exists()) {
            System.out.println("Special-casing function " + fname);
            copy("stubs/jsr239/" + fname + ".java-1" + version + "-if", glStream);
            copy("stubs/jsr239/" + fname + ".java-impl", glImplStream);
            copy("stubs/jsr239/" + fname + ".cpp", cStream);
            // Register native function names
            // This should be improved to require fewer discrete files
            String filename = "stubs/jsr239/" + fname + ".nativeReg";
            BufferedReader br = new BufferedReader(new FileReader(filename));
            String nfunc;
            while ((nfunc = br.readLine()) != null) {
                emitter.addNativeRegistration(nfunc);
            }
        } else {
            emitter.setVersion(version, ext, pack);
            emitter.emitCode(cfunc, s);
        }
    }
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File)

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