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;
}
}
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 ");
}
}
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) {
}
}
}
}
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();
}
}
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);
}
}
}
Aggregations