Java Examples for java.io.FileReader
The following java examples will help you to understand the usage of java.io.FileReader. These source code samples are taken from different open source projects.
Example 1
| Project: Beneath-master File: FileUtils.java View source code |
public static String loadAsString(String file) {
String result = "";
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String buffer = "";
while ((buffer = reader.readLine()) != null) {
result += buffer + "\n";
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}Example 2
| Project: Cherno-master File: FileUtils.java View source code |
public static String loadText(String path) {
String result = "";
try {
BufferedReader reader = new BufferedReader(new FileReader(path));
String buffer;
while ((buffer = reader.readLine()) != null) {
result += buffer + "\n";
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}Example 3
| Project: com.idega.core-master File: FileStringReader.java View source code |
public static String FileToString(String fileName, String theFilePath) throws Exception {
FileReader reader = new FileReader(theFilePath + fileName);
StringBuffer fileString = new StringBuffer("\n");
char[] charArr = new char[10];
while (reader.read(charArr) != -1) {
fileString.append(String.copyValueOf(charArr));
}
reader.close();
return fileString.toString();
}Example 4
| Project: platform2-master File: FileStringReader.java View source code |
public static String FileToString(String fileName, String theFilePath) throws Exception {
FileReader reader = new FileReader(theFilePath + fileName);
StringBuffer fileString = new StringBuffer("\n");
char[] charArr = new char[10];
while (reader.read(charArr) != -1) {
fileString.append(String.copyValueOf(charArr));
}
return fileString.toString();
}Example 5
| Project: commons-master File: FileEchoer.java View source code |
@Override
public String echo() throws IOException {
Closer closer = Closer.create();
try {
FileReader fileReader = closer.register(new FileReader("/etc/hosts"));
BufferedReader bufferedReader = closer.register(new BufferedReader(fileReader));
return bufferedReader.readLine();
} finally {
closer.close();
}
}Example 6
| Project: droidmon-master File: Files.java View source code |
public static String readFile(String filename) throws FileNotFoundException, IOException {
//Get the text file
File file = new File(filename);
//Read text from file
StringBuilder text = new StringBuilder();
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
br.close();
return text.toString();
}Example 7
| Project: GOOL-master File: RecognizerMatcherTest.java View source code |
/**
* @param args
*/
public static void main(String[] args) {
RecognizerMatcher.init("java");
RecognizerMatcher.matchImport("java.io.File");
RecognizerMatcher.printMatchTables();
System.out.println(RecognizerMatcher.matchClass("java.io.File"));
System.out.println(RecognizerMatcher.matchClass("java.io.FileReader"));
System.out.println(RecognizerMatcher.matchClass("java.io.FileWriter"));
System.out.println(RecognizerMatcher.matchClass("java.io.BufferedReader"));
System.out.println(RecognizerMatcher.matchClass("java.io.BufferedWriter"));
System.out.println(RecognizerMatcher.matchMethod("java.io.File.createNewFile():boolean"));
}Example 8
| Project: intellij-samples-master File: SmartStep.java View source code |
public static void main(String[] args) throws IOException {
System.out.println("You can smart step into a specific call on the line below");
BufferedReader reader = new BufferedReader(new FileReader("README.md"));
try {
String data = reader.readLine();
System.out.println(data);
} finally {
reader.close();
}
}Example 9
| Project: jeql-master File: TestKmlObjectReader.java View source code |
void run() throws Exception {
String filename = "C:\\data\\martin\\proj\\geodata\\world\\namePieSmall.kml";
KMLObjectReader rdr = new KMLObjectReader();
rdr.open(new FileReader(filename));
while (true) {
Placemark pm = rdr.next();
if (pm == null)
break;
System.out.println(pm);
}
}Example 10
| Project: jgrasstools-master File: Files.java View source code |
public static String readFully(String name) {
StringBuilder b = new StringBuilder();
try {
BufferedReader r = new BufferedReader(new FileReader(name));
String line;
while ((line = r.readLine()) != null) {
b.append(line).append('\n');
}
r.close();
} catch (IOException E) {
throw new ComponentException(E.getMessage());
}
return b.toString();
}Example 11
| Project: LambdaDojo-master File: S405StreamInsteadOfFor.java View source code |
private void fileRead(String filename) {
try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
int wordCount = 0;
for (; ; ) {
String line = reader.readLine();
if (line == null) {
break;
}
String[] words = line.split("[\\.,\\?; ]");
wordCount += words.length;
}
System.out.println(wordCount);
} catch (IOException ex) {
}
}Example 12
| Project: OMS3-master File: Files.java View source code |
public static String readFully(String name) {
StringBuilder b = new StringBuilder();
try {
BufferedReader r = new BufferedReader(new FileReader(name));
String line;
while ((line = r.readLine()) != null) {
b.append(line).append('\n');
}
r.close();
} catch (IOException E) {
throw new ComponentException(E.getMessage());
}
return b.toString();
}Example 13
| Project: plang-master File: u.java View source code |
public static void main(String[] a) {
try {
Runner prg = Parser.parse(new FileReader("test.in"));
prg.run();
} catch (java.io.IOException e) {
System.out.println("IOEx: " + e);
e.printStackTrace();
} catch (Tokenizer.TokEx e) {
System.out.println("TokEx: " + e);
e.printStackTrace();
}
}Example 14
| Project: posClient-master File: JsonParser.java View source code |
public static String getJsonRespon(String jsonPath) {
String jsonString = "";
try {
File jsonFile = new File(jsonPath);
// oldJsonPath = jsonPath;
FileReader in = new FileReader(jsonFile);
BufferedReader stdin = new BufferedReader(in);
String jsonString1 = null;
while (((jsonString1 = stdin.readLine()) != null)) {
jsonString = jsonString + jsonString1;
}
in.close();
} catch (Exception e) {
}
return jsonString;
}Example 15
| Project: rootbeer1-master File: ReadFile.java View source code |
public String read() throws Exception {
StringBuilder ret = new StringBuilder();
BufferedReader reader = new BufferedReader(new FileReader(m_Filename));
while (true) {
String line = reader.readLine();
if (line == null)
break;
ret.append(line);
ret.append("\n");
}
return ret.toString();
}Example 16
| Project: schach-master File: ListReader.java View source code |
public static ArrayList<String> loadStrings(File aFile) {
ArrayList<String> pVec = new ArrayList<String>();
if (!aFile.exists())
return pVec;
try {
BufferedReader pReader = new BufferedReader(new FileReader(aFile));
String pLine;
while ((pLine = pReader.readLine()) != null) {
pLine = pLine.trim();
if (pLine.startsWith("#") || pLine.equals(""))
continue;
pVec.add(pLine);
}
pReader.close();
} catch (IOException aE) {
aE.printStackTrace();
}
return pVec;
}Example 17
| Project: SDP2011-Robotniks-master File: ListReader.java View source code |
public static ArrayList<String> loadStrings(File aFile) {
ArrayList<String> pVec = new ArrayList<String>();
if (!aFile.exists())
return pVec;
try {
BufferedReader pReader = new BufferedReader(new FileReader(aFile));
String pLine;
while ((pLine = pReader.readLine()) != null) {
pLine = pLine.trim();
if (pLine.startsWith("#") || pLine.equals(""))
continue;
pVec.add(pLine);
}
pReader.close();
} catch (IOException aE) {
aE.printStackTrace();
}
return pVec;
}Example 18
| Project: szeke-master File: FileIOOps.java View source code |
public static ArrayList<String> allLinesFromFile(String file, boolean removeEmptyLines) {
ArrayList<String> lines = new ArrayList<String>();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line = "";
while (true) {
if ((line = br.readLine()) == null) {
break;
}
line = line.trim();
if (line.length() != 0 || !removeEmptyLines) {
lines.add(line);
}
}
br.close();
} catch (Exception e) {
Prnt.endIt("FileIOOps.allLinesFromFile: Error in reading file " + file + ". Exiting.");
}
return lines;
}Example 19
| Project: uservoice-java-master File: Test.java View source code |
@SuppressWarnings("unchecked")
protected String config(String name, String defaultValue) {
if (configuration == null) {
try {
configuration = new Yaml().loadAs(new FileReader("config.yml"), Map.class);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
if (configuration.get(name) == null) {
return defaultValue;
}
return configuration.get(name);
}Example 20
| Project: wikitionary-solr-synonyms-master File: FileUtil.java View source code |
/**
* Read contents of a file into a string.
* @param file
* @return file contents.
*/
public static String readFile(String fileName) {
try {
BufferedReader br = new BufferedReader(new FileReader(fileName));
StringBuffer sb = new StringBuffer();
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line);
sb.append('\n');
}
br.close();
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}Example 21
| Project: android_libcore-master File: FileReaderTest.java View source code |
/**
* @tests java.io.FileReader#FileReader(java.io.File)
*/
@TestTargetNew(level = TestLevel.COMPLETE, method = "FileReader", args = { java.io.File.class })
public void test_ConstructorLjava_io_File() {
// Test for method java.io.FileReader(java.io.File)
try {
bw = new BufferedWriter(new FileWriter(f.getPath()));
bw.write(" After test string", 0, 18);
bw.close();
br = new FileReader(f);
char[] buf = new char[100];
int r = br.read(buf);
br.close();
assertEquals("Test 1: Failed to read correct chars", " After test string", new String(buf, 0, r));
} catch (Exception e) {
fail("Exception during Constructor test " + e.toString());
}
File noFile = new File(System.getProperty("java.io.tmpdir"), "noreader.tst");
try {
br = new FileReader(noFile);
fail("Test 2: FileNotFoundException expected.");
} catch (FileNotFoundException e) {
}
}Example 22
| Project: Grindstone-master File: IO.java View source code |
public static String readFile(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[32 * 1024];
int read = 0;
while ((read = reader.read(buffer)) > 0) {
writer.write(buffer, 0, read);
}
return writer.toString();
} finally {
reader.close();
}
}Example 23
| Project: java2haxe-master File: IO.java View source code |
public static String readFile(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[32 * 1024];
int read = 0;
while ((read = reader.read(buffer)) > 0) {
writer.write(buffer, 0, read);
}
return writer.toString();
} finally {
reader.close();
}
}Example 24
| Project: open-mika-master File: jdk11.java View source code |
public void test(TestHarness testharness) {
TestHarness harness = testharness;
harness.setclass("java.io.FileReader");
String tmpfile = harness.getTempDirectory() + File.separator + "mauve-jdk11.tst";
File f = new File(tmpfile);
// Make sure the file exists.
try {
f.createNewFile();
} catch (IOException ioe) {
harness.debug(ioe);
}
try {
FileReader fr1 = new FileReader(tmpfile);
harness.check(true, "FileReader(string)");
} catch (FileNotFoundException e) {
harness.fail("Can't open file " + tmpfile);
}
try {
File f2 = new File(tmpfile);
FileReader fr2 = new FileReader(f2);
harness.check(true, "FileReader(File)");
FileInputStream fis = new FileInputStream(f2);
try {
FileReader fr3 = new FileReader(fis.getFD());
harness.check(true, "FileReader(FileDescriptor)");
} catch (IOException e) {
harness.fail("Couldn't get FileDescriptor)");
}
} catch (FileNotFoundException e) {
harness.fail("Can't open file " + tmpfile);
}
// Cleanup
f.delete();
}Example 25
| Project: sharp-master File: IO.java View source code |
public static String readFile(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[32 * 1024];
int read = 0;
while ((read = reader.read(buffer)) > 0) {
writer.write(buffer, 0, read);
}
return writer.toString();
} finally {
reader.close();
}
}Example 26
| Project: sharpen-master File: IO.java View source code |
public static String readFile(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[32 * 1024];
int read = 0;
while ((read = reader.read(buffer)) > 0) {
writer.write(buffer, 0, read);
}
return writer.toString();
} finally {
reader.close();
}
}Example 27
| Project: sharpen_imazen-master File: IO.java View source code |
public static String readFile(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[32 * 1024];
int read = 0;
while ((read = reader.read(buffer)) > 0) {
writer.write(buffer, 0, read);
}
return writer.toString();
} finally {
reader.close();
}
}Example 28
| Project: XobotOS-master File: IO.java View source code |
public static String readFile(File file) throws IOException {
FileReader reader = new FileReader(file);
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[32 * 1024];
int read = 0;
while ((read = reader.read(buffer)) > 0) {
writer.write(buffer, 0, read);
}
return writer.toString();
} finally {
reader.close();
}
}Example 29
| Project: Acernis-v144-master File: LoadPacket.java View source code |
public static byte[] getPacket() {
Properties packetProps = new Properties();
InputStreamReader is;
try {
is = new FileReader("CPacket.txt");
packetProps.load(is);
is.close();
} catch (IOException ex) {
System.out.println("Failed to load CPacket.txt");
}
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.write(HexTool.getByteArrayFromHexString(packetProps.getProperty("packet")));
return mplew.getPacket();
}Example 30
| Project: acs-master File: Cvs2clXmlParser.java View source code |
public Document parseXml(File xmlFile) throws ParserConfigurationException, FileNotFoundException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
// parse the XML file into a DOM
Document parentDoc = builder.parse(new InputSource(new FileReader(xmlFile)));
return parentDoc;
}Example 31
| Project: aio-video-downloader-master File: FileTool.java View source code |
//Get string from a text file.
@TargetApi(Build.VERSION_CODES.KITKAT)
public static String getStringFromFile(File file) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file.getPath()));
StringBuilder stringBuilder = new StringBuilder();
String line = bufferedReader.readLine();
while (line != null) {
stringBuilder.append(line);
stringBuilder.append(System.lineSeparator());
line = bufferedReader.readLine();
}
String allText = stringBuilder.toString();
//close the buffer.
bufferedReader.close();
return allText;
}Example 32
| Project: Akin-master File: Main.java View source code |
public static void main(String[] args) throws Exception {
Reader reader = null;
boolean debug = false;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-e"))
reader = new StringReader(args[++i]);
else if (args[i].equals("-d"))
debug = true;
else
reader = new FileReader(args[i]);
}
if (reader == null) {
System.out.println("usage: akin [-d] < -e code | file.akin >");
System.exit(1);
}
Bootstrapper.run().eval(reader);
}Example 33
| Project: Amoeba-Plus-For-MySQL-master File: Utils.java View source code |
public static Properties readGlobalSeqConfigProps() throws IOException {
Properties props = new Properties();
String amoebaHomePath = ProxyRuntimeContext.getInstance().getAmoebaHomePath();
String PATH_SEPARATOR = StringUtil.PATH_SEPARATOR;
String seqConfigPath = amoebaHomePath + PATH_SEPARATOR + "conf" + PATH_SEPARATOR + SEQ_CONFIG_FILENAME;
FileReader reader = new FileReader(seqConfigPath);
props.load(reader);
return props;
}Example 34
| Project: android-sdk-sources-for-api-level-23-master File: FileReaderTest.java View source code |
/**
* java.io.FileReader#FileReader(java.io.File)
*/
public void test_ConstructorLjava_io_File() throws IOException {
bw = new BufferedWriter(new FileWriter(f.getPath()));
bw.write(" After test string", 0, 18);
bw.close();
br = new FileReader(f);
char[] buf = new char[100];
int r = br.read(buf);
br.close();
assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r));
}Example 35
| Project: ARTPart-master File: FileReaderTest.java View source code |
/**
* java.io.FileReader#FileReader(java.io.File)
*/
public void test_ConstructorLjava_io_File() throws IOException {
bw = new BufferedWriter(new FileWriter(f.getPath()));
bw.write(" After test string", 0, 18);
bw.close();
br = new FileReader(f);
char[] buf = new char[100];
int r = br.read(buf);
br.close();
assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r));
}Example 36
| Project: Assignments-master File: JSONParser.java View source code |
public static Dictionary readFromJson() {
Gson gson = new Gson();
try {
BufferedReader br = new BufferedReader(new FileReader("dictionary.json"));
Dictionary dictionary = gson.fromJson(br, Dictionary.class);
return dictionary;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}Example 37
| Project: audit-master File: MainActivity.java View source code |
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
File file = new File("/sdcard/test.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
String tempString = null;
while ((tempString = reader.readLine()) != null) {
Log.e("testcaseLog", tempString);
Runtime.getRuntime().exec(tempString);
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
}Example 38
| Project: BACKUP_FROM_SVN-master File: NoJavaSpecificCodeTest.java View source code |
// @Test
// public void checkJavaCode() throws Exception {
// checkJavaClasses(new File(TestContext.getInstance().findCoreProjectRoot(), "src/java"));
// }
private void checkJavaClasses(File directory) throws Exception {
for (File file : directory.listFiles()) {
if (file.getName().endsWith(".java")) {
BufferedReader reader = new BufferedReader(new FileReader(file));
try {
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("java.sql")) {
fail(file.getCanonicalPath() + " contains java.sql");
}
}
} finally {
reader.close();
}
} else if (file.isDirectory()) {
checkJavaClasses(file);
}
}
}Example 39
| Project: Bio-PEPA-master File: DataReader.java View source code |
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("CompanyName: [" + nextLine[0] + "]\nCompanyNumber: [" + nextLine[1] + "]\nClientName: [" + nextLine[2] + "]");
System.out.println("ClientFirstName: [" + nextLine[3] + "]\nClientLastName: [" + nextLine[4] + "]\nClientId: [" + nextLine[5] + "]");
System.out.println("ClientGroupId: [" + nextLine[6] + "]\nLogon: [" + nextLine[7] + "]\nLogonPW: [" + nextLine[8] + "]");
System.out.println("PublishKey: [" + nextLine[9] + "]\nHiddenKey: [" + nextLine[10] + "]\nPublishEncryptMode: [" + nextLine[11] + "]");
System.out.println("LanFolderId: [" + nextLine[12] + "]\nStaffId: [" + nextLine[13] + "]\n");
}
}Example 40
| Project: brightkite4j-master File: UtilsForTesting.java View source code |
private static String readFromFile(File file) throws IOException {
Reader is = new FileReader(file);
StringBuffer sb = new StringBuffer();
char[] b = new char[MAX_TEST_DATA_FILE_SIZE];
int n;
// Read a block. If it gets any chars, append them.
while ((n = is.read(b)) > 0) {
sb.append(b, 0, n);
}
// Only construct the String object once, here.
return sb.toString();
}Example 41
| Project: chess-misc-master File: CreateImage.java View source code |
private static void readAndConvert() {
String fen;
int counter = 0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(new File(FILE_PATH)));
while ((fen = br.readLine()) != null) {
if (!DrawBoard.fenToPng(fen))
System.out.println("Oops! Check code..");
Thread.sleep(50);
counter++;
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(counter + " images created.");
}Example 42
| Project: CIAPI.Java-master File: TemplateFillerTest.java View source code |
@Test
public void testLoadTemplate() throws FileNotFoundException, ClassNotFoundException {
ReplacementRoot repl = new ReplacementRoot("files/test/TestReplacementFile.xml");
TemplateFiller filler = new TemplateFiller(repl);
QuoteSet set = new Gson().fromJson(new FileReader(new File("files/test/quotes.js")), QuoteSet.class);
String code = filler.fillTemplate(set);
assertTrue(true);
}Example 43
| Project: cl1p.net-source-master File: ClipMsg.java View source code |
public static void loadMsgFile() {
try {
File file = new File("/home/rob/cl1p.msg");
if (file.exists()) {
BufferedReader in = new BufferedReader(new FileReader(file));
StringBuffer sb = new StringBuffer();
while (in.ready()) {
sb.append(in.readLine());
}
in.close();
msg = sb.toString();
}
} catch (IOException e) {
log.error("Error loading msg", e);
}
}Example 44
| Project: clojure-jsr223-master File: EvalFile.java View source code |
/*
* Let us assume that we have the file named "test.clj" with the following text:
*
* (println "This is hello from test.clj")
*
* We can run the above Java as
*
* java -cp clojure.jar;clojure-contrib.jar;clojure-223.jar EvalFile test.clj
*/
public static void main(String[] args) throws Exception {
// create a script engine manager
ScriptEngineManager factory = new ScriptEngineManager();
// create Clojure engine
ScriptEngine engine = factory.getEngineByName("Clojure");
// evaluate Clojure code from given file - specified by first argument
engine.eval(new java.io.FileReader(args[0]));
}Example 45
| Project: cloudwatch_exporter-master File: WebServer.java View source code |
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: WebServer <port> <yml configuration file>");
System.exit(1);
}
CloudWatchCollector cc = new CloudWatchCollector(new FileReader(args[1])).register();
int port = Integer.parseInt(args[0]);
Server server = new Server(port);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
context.addServlet(new ServletHolder(new HomePageServlet()), "/");
server.start();
server.join();
}Example 46
| Project: cogroo4-master File: ResourcesUtil.java View source code |
public static String getResourceAsString(Class<?> theClass, String fileName) throws IOException {
File f = new File(theClass.getResource(fileName).getFile());
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line + "\n");
line = br.readLine();
}
br.close();
return sb.toString();
}Example 47
| Project: ComplexEventProcessingPlatform-master File: TomTomHelper.java View source code |
public static ArrayList<String> getStreetnumbersOfExampleUsecase() throws IOException {
ArrayList<String> streetnumbers = new ArrayList<String>();
BufferedReader fileInput = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/src/main/resources/StreetNumbersOfExampleUseCase.txt"));
ArrayList<String> streets = new ArrayList<String>();
String readline;
while ((readline = fileInput.readLine()) != null) {
streets.addAll(Arrays.asList(readline.split(";")));
}
return streets;
}Example 48
| Project: constellio-master File: ExtractDocumentTypeCodes.java View source code |
public static void main(String[] args) {
File file = new File("/Users/rodrigue/constellio-dev-2015-10-08/documentTypes.txt");
assertThat(file).exists();
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
String line = "";
while (StringUtils.isNotBlank(line = bufferedReader.readLine())) {
String codePart = StringUtils.substringAfter(line, "code:");
if (StringUtils.isNotBlank(codePart)) {
if (StringUtils.split(codePart, ", ").length > 0) {
String code = StringUtils.split(codePart, ", ")[0];
System.out.println(code);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}Example 49
| Project: coursework-master File: FinallyApp.java View source code |
private void startProgram() {
File file = new File("names.txt");
FileReader fileReader = null;
BufferedReader reader = null;
try {
fileReader = new FileReader(file);
reader = new BufferedReader(fileReader);
} catch (FileNotFoundException fnfe) {
System.out.println("File not found " + file);
} finally {
closeReaders(reader);
}
}Example 50
| Project: CrowdBenchmark-master File: TxtReader.java View source code |
public void readfile(String filename) {
String path = filename;
StringBuffer buffer = new StringBuffer();
try {
BufferedReader dataInput = new BufferedReader(new FileReader(new File(path)));
String line;
while ((line = dataInput.readLine()) != null) {
// buffer.append(cleanLine(line.toLowerCase()));
buffer.append(line);
buffer.append('\n');
}
dataInput.close();
} catch (Exception ex) {
ex.printStackTrace();
}
content = buffer.toString();
}Example 51
| Project: cse446_p3-master File: TaggerDemo.java View source code |
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("usage: java TaggerDemo modelFile fileToTag");
return;
}
MaxentTagger tagger = new MaxentTagger(args[0]);
@SuppressWarnings("unchecked") List<ArrayList<? extends HasWord>> sentences = tagger.tokenizeText(new BufferedReader(new FileReader(args[1])));
for (ArrayList<? extends HasWord> sentence : sentences) {
ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);
System.out.println(Sentence.listToString(tSentence, false));
}
}Example 52
| Project: css-analyser-master File: ModifiedLessFileSource.java View source code |
@Override
public String getContent() throws FileNotFound, CannotReadFile {
try {
Reader input;
input = new FileReader(getInputFile());
try {
// .replace("\r\n", "\n");
String content = IOUtils.toString(input);
setLastModified(getInputFile().lastModified());
return content;
} finally {
input.close();
}
} catch (FileNotFoundException ex) {
throw new FileNotFound();
} catch (IOException ex) {
throw new CannotReadFile();
}
}Example 53
| Project: Dead-Reckoning-Android-master File: DataReader.java View source code |
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("CompanyName: [" + nextLine[0] + "]\nCompanyNumber: [" + nextLine[1] + "]\nClientName: [" + nextLine[2] + "]");
System.out.println("ClientFirstName: [" + nextLine[3] + "]\nClientLastName: [" + nextLine[4] + "]\nClientId: [" + nextLine[5] + "]");
System.out.println("ClientGroupId: [" + nextLine[6] + "]\nLogon: [" + nextLine[7] + "]\nLogonPW: [" + nextLine[8] + "]");
System.out.println("PublishKey: [" + nextLine[9] + "]\nHiddenKey: [" + nextLine[10] + "]\nPublishEncryptMode: [" + nextLine[11] + "]");
System.out.println("LanFolderId: [" + nextLine[12] + "]\nStaffId: [" + nextLine[13] + "]\n");
}
}Example 54
| Project: deepnighttwo-master File: RL.java View source code |
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException, InterruptedException {
String filepath = args[0];
while (true) {
BufferedReader br = new BufferedReader(new FileReader(filepath), 2 << 17);
System.out.println("Press Enter to start...");
while (System.in.read() != '\n') ;
int lineTotal = 0;
int linePre = 0;
long start = System.currentTimeMillis();
long totalStart = System.currentTimeMillis();
while (br.readLine() != null) {
lineTotal++;
if (lineTotal % 100000 == 0) {
long end = System.currentTimeMillis();
System.out.println("total speed=" + lineTotal / (end - totalStart) + "k/s. curr speed=" + (lineTotal - linePre) / (end - start));
start = end;
linePre = lineTotal;
}
}
}
}Example 55
| Project: DoSeR-master File: MergeEntityLists.java View source code |
public static void main(String[] args) throws Exception {
HashSet<String> set = new HashSet<String>();
PrintWriter writer = new PrintWriter("/home/zwicklbauer/WikipediaEntities/entityListMerged.dat");
BufferedReader reader1 = new BufferedReader(new FileReader(new File("/home/zwicklbauer/WikipediaEntities/entityList.dat")));
String line = null;
while ((line = reader1.readLine()) != null) {
set.add(line);
}
BufferedReader reader2 = new BufferedReader(new FileReader(new File("/home/zwicklbauer/WikipediaEntities/entityList_Big.dat")));
line = null;
while ((line = reader2.readLine()) != null) {
set.add(line);
}
for (String s : set) {
writer.println(s);
}
reader1.close();
reader2.close();
writer.close();
}Example 56
| Project: find-sec-bugs-master File: PathTraversal.java View source code |
public static void main(String[] args) throws IOException, URISyntaxException {
String input = args.length > 0 ? args[0] : "../../../../etc/password";
new File(input);
new File("test/" + input, "misc.jpg");
new RandomAccessFile(input, "r");
new File(new URI(args[0]));
new FileReader(input);
new FileInputStream(input);
new FileWriter(input);
new FileWriter(input, true);
new FileOutputStream(input);
new FileOutputStream(input, true);
// false positive test
new RandomAccessFile("safe", args[0]);
new FileWriter("safe".toUpperCase());
new File(new URI("safe"));
}Example 57
| Project: fly-gdx-master File: DesktopLauncher.java View source code |
public static void main(String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "FLY";
config.width = 960;
config.height = 640;
// config.fullscreen = true;
new LwjglApplication(new Fly(), config);
try {
Scanner in = new Scanner(new FileReader("DesktopVersion.txt"));
Fly.VERSION = in.nextLine().substring(8);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}Example 58
| Project: geotools-master File: WorldFileWriterTest.java View source code |
@Test
public void testWrite() throws Exception {
AffineTransform at = new AffineTransform(42.34, 0, 0, -42.34, 347671.10, 5196940.18);
File tmp = File.createTempFile("write", "wld", new File("target"));
new WorldFileWriter(tmp, at);
BufferedReader r = new BufferedReader(new FileReader(tmp));
assertEquals(42.34, Double.parseDouble(r.readLine()), 0.1);
assertEquals(0, Double.parseDouble(r.readLine()), 0.1);
assertEquals(0, Double.parseDouble(r.readLine()), 0.1);
assertEquals(-42.34, Double.parseDouble(r.readLine()), 0.1);
assertEquals(347671.10, Double.parseDouble(r.readLine()), 0.1);
assertEquals(5196940.18, Double.parseDouble(r.readLine()), 0.1);
assertNull(r.readLine());
}Example 59
| Project: ggp-base-master File: FileUtils.java View source code |
public static String readFileAsString(File file) {
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
StringBuilder fileData = new StringBuilder(10000);
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
fileData.append(buf, 0, numRead);
}
return fileData.toString();
} catch (FileNotFoundException e) {
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}Example 60
| Project: guide-master File: Nashorn1.java View source code |
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(new FileReader("res/nashorn1.js"));
Invocable invocable = (Invocable) engine;
Object result = invocable.invokeFunction("fun1", "Peter Parker");
System.out.println(result);
System.out.println(result.getClass());
invocable.invokeFunction("fun2", new Date());
invocable.invokeFunction("fun2", LocalDateTime.now());
invocable.invokeFunction("fun2", new Person());
}Example 61
| Project: Holo-File-Explorer-master File: RootSupport.java View source code |
public static ArrayList<ExtendedMount> getMounts() throws FileNotFoundException, IOException {
LineNumberReader lnr = null;
try {
lnr = new LineNumberReader(new FileReader("/proc/mounts"));
String line;
ArrayList<ExtendedMount> mounts = new ArrayList<ExtendedMount>();
while ((line = lnr.readLine()) != null) {
String[] fields = line.split(" ");
mounts.add(new ExtendedMount(new // device
File(// device
fields[0]), // mountPoint
new File(fields[1]), // fstype
fields[2], // flags
fields[3]));
}
return mounts;
} finally {
// no need to do anything here.
}
}Example 62
| Project: HtmlNative-master File: Utils.java View source code |
public static String toString(File file) {
StringBuilder content = new StringBuilder();
FileReader fileReader = null;
BufferedReader bufferedReader = null;
try {
fileReader = new FileReader(file);
bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
content.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException ignored) {
} finally {
try {
if (fileReader != null) {
fileReader.close();
}
} catch (IOException ignored) {
}
}
}
return content.toString();
}Example 63
| Project: intellij-community-master File: IpnbTestCase.java View source code |
static String getFileText(@NotNull final String fileName) throws IOException {
String fullPath = PathManager.getHomePath() + "/community/python/ipnb/" + fileName;
final BufferedReader br = new BufferedReader(new FileReader(fullPath));
try {
final StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append("\n");
line = br.readLine();
}
return sb.toString();
} finally {
br.close();
}
}Example 64
| Project: jacorb-master File: ReproServiceMainSpring.java View source code |
public static void main(String[] args) throws IOException {
Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
props.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
new ClassPathXmlApplicationContext(new String[] { "repro-service-context.xml" });
File f = new File(ReproClientTest.IOR);
while (!f.exists()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
BufferedReader br = new BufferedReader(new FileReader(f));
String ior = br.readLine();
br.close();
System.out.println("SERVER IOR: " + ior);
while (true) {
}
}Example 65
| Project: japura-gui-master File: CountryNames.java View source code |
public static List<String> getCountries() {
List<String> list = new ArrayList<String>();
Class<?> cls = CountryNames.class;
URL url = cls.getResource("/countries.txt");
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(url.getFile()));
String text = null;
while ((text = reader.readLine()) != null) {
list.add(text);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return list;
}Example 66
| Project: java-game-server-master File: SmallFileReader.java View source code |
public static String readSmallFile(File smallFile) throws IOException {
FileReader reader = new FileReader(smallFile);
BufferedReader bufferedReader = new BufferedReader(reader);
StringBuffer buf = new StringBuffer();
String line = null;
while ((line = bufferedReader.readLine()) != null) {
buf.append(line);
}
bufferedReader.close();
reader.close();
return buf.toString();
}Example 67
| Project: java8-tutorial-master File: Nashorn1.java View source code |
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(new FileReader("res/nashorn1.js"));
Invocable invocable = (Invocable) engine;
Object result = invocable.invokeFunction("fun1", "Peter Parker");
System.out.println(result);
System.out.println(result.getClass());
invocable.invokeFunction("fun2", new Date());
invocable.invokeFunction("fun2", LocalDateTime.now());
invocable.invokeFunction("fun2", new Person());
}Example 68
| Project: jFlowLib-master File: PcapToJavaByteConverter.java View source code |
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new FileReader(new File("test/net/decix/jsflow/utils/sflowByte2.txt")));
String byteString = new String("byte[] data = {");
String line = null;
while ((line = br.readLine()) != null) {
int counterLine = 0;
StringTokenizer st = new StringTokenizer(line);
while (st.hasMoreTokens()) {
if (counterLine == 0) {
st.nextToken();
counterLine++;
continue;
} else {
byteString += " (byte) 0x" + st.nextToken();
}
if (st.hasMoreTokens() || br.ready())
byteString += ",";
if (!st.hasMoreTokens()) {
System.out.println(byteString);
byteString = "";
}
counterLine++;
}
}
byteString += " };";
System.out.println(byteString);
}Example 69
| Project: JSRefactor-master File: TestUtil.java View source code |
public static Start parseFile(File file) {
try {
Start root = new Parser(new SemicolonInsertingLexer(new PushbackReader(new FileReader(file), 256))).parse();
PrintStream stream = new PrintStream(new File("output/" + file.getName() + "-ast.txt"));
try {
root.apply(new ASTPrinter(stream));
} finally {
stream.close();
}
return root;
} catch (Exception ex) {
throw new RuntimeException("\r\n" + ex.getMessage(), ex);
}
}Example 70
| Project: jStellarAPI-master File: TestUtilities.java View source code |
public static StellarSeedAddress getTestSeed() throws Exception {
if (stellarAccount == null) {
JSONObject jsonWallet = (JSONObject) new JSONParser().parse(new FileReader("secrets/jStellarAPI-wallet.json"));
String seedStr = (String) jsonWallet.get("master_seed");
stellarAccount = new StellarSeedAddress(seedStr);
}
return stellarAccount;
}Example 71
| Project: jWic-master File: ChartHelper.java View source code |
public static String getFileContent(String fileName) {
StringBuilder contentBuilder = new StringBuilder();
if (fileName != null) {
File file = new File(fileName);
if (file != null && file.exists()) {
try {
BufferedReader in = new BufferedReader(new FileReader(fileName));
String str;
while ((str = in.readLine()) != null) {
contentBuilder.append(str);
}
in.close();
} catch (IOException e) {
}
String content = contentBuilder.toString();
return content;
} else {
return "";
}
}
return null;
}Example 72
| Project: Katari-master File: HibernateUtilsTest.java View source code |
public void testMain() throws Exception {
HibernateUtils.main(new String[] { "classpath:/com/globant/katari/tools/applicationContext.xml", "target/test.ddl" });
// Open the file and check for 'create table ...
FileReader in = new FileReader("target/test.ddl");
char[] buffer = new char[4096];
in.read(buffer, 0, 4096);
String file = new String(buffer);
assertTrue(file.contains("create table clients ("));
assertTrue(file.contains("create table projects ("));
assertTrue(file.contains("create table activities ("));
in.close();
}Example 73
| Project: kibana-master File: DemoDataProcessor.java View source code |
@Override
public List<String> process(File inItem) {
List<String> outItems = null;
try {
BufferedReader in = new BufferedReader(new FileReader(inItem));
String s;
//pass first line
in.readLine();
s = in.readLine();
if (s != null) {
Json json = new Json(s);
outItems = json.jsonPath("$.data[*].[*]").all();
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return outItems;
}Example 74
| Project: liquibase-master File: NoJavaSpecificCodeTest.java View source code |
// @Test
// public void checkJavaCode() throws Exception {
// checkJavaClasses(new File(TestContext.getInstance().findCoreProjectRoot(), "src/java"));
// }
private void checkJavaClasses(File directory) throws Exception {
for (File file : directory.listFiles()) {
if (file.getName().endsWith(".java")) {
BufferedReader reader = new BufferedReader(new FileReader(file));
try {
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("java.sql")) {
fail(file.getCanonicalPath() + " contains java.sql");
}
}
} finally {
reader.close();
}
} else if (file.isDirectory()) {
checkJavaClasses(file);
}
}
}Example 75
| Project: MiA-master File: WikipediaDataConverter.java View source code |
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("links-simple-sorted.txt"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("links-converted.txt")));
String line;
while ((line = in.readLine()) != null) {
Matcher m = NUMBERS.matcher(line);
m.find();
long userID = Long.parseLong(m.group());
while (m.find()) {
out.println(userID + "," + Long.parseLong(m.group()));
}
}
in.close();
out.close();
}Example 76
| Project: MinecraftForkage-master File: ApplySRGTask.java View source code |
@Override
public void execute() throws BuildException {
if (input == null)
throw new BuildException("Input not specified");
if (output == null)
throw new BuildException("Output not specified");
if (srg == null)
throw new BuildException("SRG not specified");
try {
ApplySRG.apply(new FileReader(srg), input, output, null);
} catch (Exception e) {
throw new BuildException(e);
}
}Example 77
| Project: mOrgAnd-master File: TestUtils.java View source code |
public static String readFileAsString(String fileName) {
StringBuilder stringBuilder = new StringBuilder();
String line;
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(new File(fileName)));
while ((line = in.readLine()) != null) stringBuilder.append(line).append("\n");
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
return stringBuilder.toString();
}Example 78
| Project: OpenCSV-3.0-master File: DataReader.java View source code |
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("CompanyName: [" + nextLine[0] + "]\nCompanyNumber: [" + nextLine[1] + "]\nClientName: [" + nextLine[2] + "]");
System.out.println("ClientFirstName: [" + nextLine[3] + "]\nClientLastName: [" + nextLine[4] + "]\nClientId: [" + nextLine[5] + "]");
System.out.println("ClientGroupId: [" + nextLine[6] + "]\nLogon: [" + nextLine[7] + "]\nLogonPW: [" + nextLine[8] + "]");
System.out.println("PublishKey: [" + nextLine[9] + "]\nHiddenKey: [" + nextLine[10] + "]\nPublishEncryptMode: [" + nextLine[11] + "]");
System.out.println("LanFolderId: [" + nextLine[12] + "]\nStaffId: [" + nextLine[13] + "]\n");
}
}Example 79
| Project: openjump-core-rels-master File: SimpleGMLReaderTestCase.java View source code |
public void test() throws Exception {
List geometries;
FileReader fileReader = new FileReader(TestUtil.toFile("3points.xml"));
try {
geometries = new SimpleGMLReader().toGeometries(fileReader, "dataFeatures", "Feature", "gml:pointProperty");
} finally {
fileReader.close();
}
assertEquals(3, geometries.size());
assertEquals(new Coordinate(1195523.78545869, 382130.432621668), ((Geometry) geometries.get(0)).getCoordinate());
}Example 80
| Project: openpixi-master File: FileIO.java View source code |
public static String readFile(File file) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
reader.close();
return stringBuilder.toString();
}Example 81
| Project: opentrader.github.com-master File: DataReader.java View source code |
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("CompanyName: [" + nextLine[0] + "]\nCompanyNumber: [" + nextLine[1] + "]\nClientName: [" + nextLine[2] + "]");
System.out.println("ClientFirstName: [" + nextLine[3] + "]\nClientLastName: [" + nextLine[4] + "]\nClientId: [" + nextLine[5] + "]");
System.out.println("ClientGroupId: [" + nextLine[6] + "]\nLogon: [" + nextLine[7] + "]\nLogonPW: [" + nextLine[8] + "]");
System.out.println("PublishKey: [" + nextLine[9] + "]\nHiddenKey: [" + nextLine[10] + "]\nPublishEncryptMode: [" + nextLine[11] + "]");
System.out.println("LanFolderId: [" + nextLine[12] + "]\nStaffId: [" + nextLine[13] + "]\n");
}
}Example 82
| Project: ORE-master File: FileHelper.java View source code |
public static String readFile(File file) throws IOException {
if (!file.exists())
return null;
StringBuilder text = new StringBuilder("");
BufferedReader reader = new BufferedReader(new FileReader(file));
try {
String line;
while ((line = reader.readLine()) != null) {
text.append(line);
text.append("\n");
}
} finally {
reader.close();
}
return text.toString();
}Example 83
| Project: Orebfuscator-master File: FileHelper.java View source code |
public static String readFile(File file) throws IOException {
if (!file.exists())
return null;
StringBuilder text = new StringBuilder("");
BufferedReader reader = new BufferedReader(new FileReader(file));
try {
String line;
while ((line = reader.readLine()) != null) {
text.append(line);
text.append("\n");
}
} finally {
reader.close();
}
return text.toString();
}Example 84
| Project: osgi-bundles-liquibase-master File: NoJavaSpecificCodeTest.java View source code |
// @Test
// public void checkJavaCode() throws Exception {
// checkJavaClasses(new File(TestContext.getInstance().findCoreProjectRoot(), "src/java"));
// }
private void checkJavaClasses(File directory) throws Exception {
for (File file : directory.listFiles()) {
if (file.getName().endsWith(".java")) {
BufferedReader reader = new BufferedReader(new FileReader(file));
try {
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("java.sql")) {
fail(file.getCanonicalPath() + " contains java.sql");
}
}
} finally {
reader.close();
}
} else if (file.isDirectory()) {
checkJavaClasses(file);
}
}
}Example 85
| Project: PersonalityExtraction-master File: SennaReader.java View source code |
/**
* @param args
*/
public static void main(String[] args) {
try {
BufferedReader fr = new BufferedReader(new FileReader(args[0]));
String line;
ArrayList<String> lines = new ArrayList<String>();
while ((line = fr.readLine()) != null) {
line = line.trim();
if (!line.equals("")) {
lines.add(line);
} else {
// @TODO create Event obj
Event e = new Event(lines);
List<String> entities = e.getEntities();
for (String entity : entities) {
System.out.println(entity);
}
lines = new ArrayList<String>();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}Example 86
| Project: proyectoAE2015-master File: Velocidad.java View source code |
/**
* Carga y devuelve una lista de velocidades.
* @param path
* @return
*/
public static Velocidad[] cargar(String path) throws FileNotFoundException {
Gson gson = new Gson();
BufferedReader br = new BufferedReader(new FileReader(path));
Velocidad[] res = gson.fromJson(br, Velocidad[].class);
//convierto todas las velocidades a segundos. Ya que viene en % / hora
for (Velocidad vel : res) {
vel.v = (vel.v / 60) / 60;
}
return res;
}Example 87
| Project: renderlabs-master File: IterableFile.java View source code |
public Iterator<String> iterator() {
ArrayList<String> lines = new ArrayList<String>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} catch (IOException io) {
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ioe) {
}
}
}
return lines.iterator();
}Example 88
| Project: rrd4j-master File: Test.java View source code |
/**
* <p>main.</p>
*
* @param args an array of {@link java.lang.String} objects.
* @throws java.io.IOException if any.
*/
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new FileReader(LOADAVG_FILE));
try {
String line = r.readLine();
if (line != null) {
String[] loads = line.split("\\s+");
if (loads.length >= 3) {
String load = loads[0] + " " + loads[1] + " " + loads[2];
System.out.println("LOAD = " + load);
return;
}
System.out.println("Unexpected error while parsing file " + LOADAVG_FILE);
}
} finally {
r.close();
}
}Example 89
| Project: sad-analyzer-master File: DataReader.java View source code |
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("CompanyName: [" + nextLine[0] + "]\nCompanyNumber: [" + nextLine[1] + "]\nClientName: [" + nextLine[2] + "]");
System.out.println("ClientFirstName: [" + nextLine[3] + "]\nClientLastName: [" + nextLine[4] + "]\nClientId: [" + nextLine[5] + "]");
System.out.println("ClientGroupId: [" + nextLine[6] + "]\nLogon: [" + nextLine[7] + "]\nLogonPW: [" + nextLine[8] + "]");
System.out.println("PublishKey: [" + nextLine[9] + "]\nHiddenKey: [" + nextLine[10] + "]\nPublishEncryptMode: [" + nextLine[11] + "]");
System.out.println("LanFolderId: [" + nextLine[12] + "]\nStaffId: [" + nextLine[13] + "]\n");
}
}Example 90
| Project: Signal-Server-master File: NetworkGauge.java View source code |
protected Pair<Long, Long> getSentReceived() throws IOException {
File proc = new File("/proc/net/dev");
BufferedReader reader = new BufferedReader(new FileReader(proc));
String header = reader.readLine();
String header2 = reader.readLine();
long bytesSent = 0;
long bytesReceived = 0;
String interfaceStats;
while ((interfaceStats = reader.readLine()) != null) {
String[] stats = interfaceStats.split("\\s+");
if (!stats[1].equals("lo:")) {
bytesReceived += Long.parseLong(stats[2]);
bytesSent += Long.parseLong(stats[10]);
}
}
return new Pair<>(bytesSent, bytesReceived);
}Example 91
| Project: sonar-java-master File: ThreadSleepCall.java View source code |
public void echoFile(PrintStream ps, File f) throws IOException, InterruptedException {
BufferedReader br = new BufferedReader(new FileReader(f));
try {
while (okToPrint) {
Thread.sleep(1000);
ps.println(br.readLine());
}
} catch (IOException ex) {
if (okToPrint) {
throw new RuntimeException("Couldn't read a line", ex);
}
throw new RuntimeException("Got an error, but it's not OK to print", ex);
}
}Example 92
| Project: ssie-versioned-master File: PerlIOFuncs.java View source code |
public static void diamond(File file, LineCallback c) {
try {
BufferedReader r = new BufferedReader(new FileReader(file));
String line = null;
while ((line = r.readLine()) != null) {
ControlStatement cont = c.handleLine(line);
switch(cont) {
case next:
continue;
case redo:
continue;
case last:
break;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}Example 93
| Project: stanford-stemming-server-master File: TaggerDemo.java View source code |
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("usage: java TaggerDemo modelFile fileToTag");
return;
}
MaxentTagger tagger = new MaxentTagger(args[0]);
@SuppressWarnings("unchecked") List<List<HasWord>> sentences = tagger.tokenizeText(new BufferedReader(new FileReader(args[1])));
for (List<HasWord> sentence : sentences) {
ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);
System.out.println(Sentence.listToString(tSentence, false));
}
}Example 94
| Project: SyncNotes-master File: FileHandler.java View source code |
public boolean registered() {
BufferedReader br;
boolean isRegistered = false;
try {
br = new BufferedReader(new FileReader(file));
String line = br.readLine();
if (line != null) {
isRegistered = false;
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
return isRegistered;
}Example 95
| Project: Syntactic-master File: WikiDump.java View source code |
@Override
public boolean open() {
if (!isOpen) {
try {
FileReader fr = new FileReader(source);
BufferedReader br = new BufferedReader(fr);
sc = new Scanner(br).useDelimiter("[\\.\\;]+?");
isOpen = true;
} catch (FileNotFoundException e) {
Console.line("ERROR: File not found at " + source.getAbsolutePath());
}
}
return isOpen;
}Example 96
| Project: TBLips-master File: JavaScriptExecutor.java View source code |
public static void main(String[] args) throws Exception {
File file = new File(args[0]);
Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();
try {
if (args.length > 1) {
for (int i = 1; i < args.length; i++) {
File includeFile = new File(args[i]);
cx.evaluateReader(scope, new FileReader(includeFile), includeFile.getName(), 1, null);
}
}
cx.evaluateReader(scope, new FileReader(file), file.getName(), 1, null);
} finally {
Context.exit();
}
}Example 97
| Project: tbx2rdf-master File: TBXResourcesTest.java View source code |
@Test
public void testAllResources() throws Exception {
final File dir = new File("samples/TBX-resources");
for (File f : dir.listFiles()) {
if (f.getName().endsWith(".tbx") && !f.getName().contains("coreInvalid") && !f.getName().contains("notWellformed")) {
System.err.println(f.getName());
TBX2RDF_Converter converter = new TBX2RDF_Converter();
//READ XML
BufferedReader reader = new BufferedReader(new FileReader(f));
final Mappings mappings = Mappings.readInMappings("mappings.default");
TBX_Terminology terminology = converter.convert(reader, mappings);
}
}
}Example 98
| Project: testCmpe131-master File: DataReader.java View source code |
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("CompanyName: [" + nextLine[0] + "]\nCompanyNumber: [" + nextLine[1] + "]\nClientName: [" + nextLine[2] + "]");
System.out.println("ClientFirstName: [" + nextLine[3] + "]\nClientLastName: [" + nextLine[4] + "]\nClientId: [" + nextLine[5] + "]");
System.out.println("ClientGroupId: [" + nextLine[6] + "]\nLogon: [" + nextLine[7] + "]\nLogonPW: [" + nextLine[8] + "]");
System.out.println("PublishKey: [" + nextLine[9] + "]\nHiddenKey: [" + nextLine[10] + "]\nPublishEncryptMode: [" + nextLine[11] + "]");
System.out.println("LanFolderId: [" + nextLine[12] + "]\nStaffId: [" + nextLine[13] + "]\n");
}
}Example 99
| Project: TextSecure-Server-master File: NetworkGauge.java View source code |
protected Pair<Long, Long> getSentReceived() throws IOException {
File proc = new File("/proc/net/dev");
BufferedReader reader = new BufferedReader(new FileReader(proc));
String header = reader.readLine();
String header2 = reader.readLine();
long bytesSent = 0;
long bytesReceived = 0;
String interfaceStats;
while ((interfaceStats = reader.readLine()) != null) {
String[] stats = interfaceStats.split("\\s+");
if (!stats[1].equals("lo:")) {
bytesReceived += Long.parseLong(stats[2]);
bytesSent += Long.parseLong(stats[10]);
}
}
return new Pair<>(bytesSent, bytesReceived);
}Example 100
| Project: umlet-master File: RunningFileChecker.java View source code |
@Override
public void run() {
try {
Path.safeCreateFile(file, false);
BufferedReader reader = new BufferedReader(new FileReader(file));
String filename = reader.readLine();
reader.close();
if (filename != null) {
Path.safeDeleteFile(file, false);
Path.safeCreateFile(file, true);
canOpenDiagram.doOpen(filename);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}Example 101
| Project: visage-compiler-master File: VSGC1865Test.java View source code |
@Test
public void VSGC1865Test() throws Exception {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("visage");
assertTrue(engine instanceof VisageScriptEngine);
File script = new File("test/src/org/visage/tools/script/VSGC1865.visage");
engine.getContext().setAttribute(ScriptEngine.FILENAME, script.getAbsolutePath(), ScriptContext.ENGINE_SCOPE);
Boolean ret = (Boolean) engine.eval(new FileReader(script));
assertTrue(ret.booleanValue());
}