Java Examples for java.io.BufferedReader
The following java examples will help you to understand the usage of java.io.BufferedReader. 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: betsy-master File: GitUtil.java View source code |
public static String getGitCommit() { Runtime rt = Runtime.getRuntime(); try { Process pr = rt.exec("git rev-parse HEAD"); try (BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()))) { String line = input.readLine(); if (line.startsWith("fatal:")) { //no commit hash return ""; } else { return line; } } } catch (IOException e) { return ""; } }
Example 3
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 4
Project: dokuJClient-master File: StdinReader.java View source code |
public String readStdin() throws IOException { StringBuilder result = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input; while ((input = br.readLine()) != null) { result.append(input + "\n"); } if (result.length() > 0) { result.delete(result.length() - 1, result.length()); } return result.toString(); }
Example 5
Project: edu-master File: ReaderDemo.java View source code |
/** * @param args */ public static void main(String[] args) { try { String s = "<html>Hallo! <p>Content im Tag.</p>\n" + "Content ausserhalb Tag.</html>"; Reader reader = new StringReader(s); BufferedReader in = new BufferedReader(reader); for (String line; (line = in.readLine()) != null; ) System.out.println(line); in.close(); } catch (Exception e) { e.printStackTrace(); } }
Example 6
Project: javamagic-master File: TestUtils.java View source code |
public static String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line); } is.close(); } catch (Exception ex) { throw new RuntimeException(ex); } return sb.toString(); }
Example 7
Project: jetty-plugin-support-master File: StreamUtils.java View source code |
public static String inputStreamToString(InputStream inputStream) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder stringBuilder = new StringBuilder(); String line = null; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line + "\n"); } bufferedReader.close(); return stringBuilder.toString(); }
Example 8
Project: sandboxes-master File: Docker.java View source code |
public String dockerIp() { try { Process process = Runtime.getRuntime().exec("docker-machine ip docker-vm"); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String ip = reader.readLine(); reader.close(); return ip; } catch (Exception e) { return "localhost"; } }
Example 9
Project: tawus-master File: TestUtils.java View source code |
public static String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line); } is.close(); } catch (Exception ex) { throw new RuntimeException(ex); } return sb.toString(); }
Example 10
Project: wifiserver-master File: StringUtil.java View source code |
public static String fromInputStream(InputStream inputStream) throws IOException { StringBuilder result = new StringBuilder(); if (inputStream != null) { String line = null; BufferedReader reader = new BufferedReader(new InputStreamReader((inputStream))); while (null != (line = reader.readLine())) { result.append(line); } } return result.toString(); }
Example 11
Project: beatles-master File: HdfsInputAdaptorTest.java View source code |
/** * @param args */ public static void main(String[] args) { HdfsInputAdaptor hdfsInputAdaptor = new HdfsInputAdaptor(); JobConfig jobConfig = new JobConfig(); JobTask jobtask = new JobTask(jobConfig); jobtask.setInput("hdfs://localhost:9000/user/apple/top/top-access.log"); java.io.BufferedReader reader = null; InputStream in = null; try { in = hdfsInputAdaptor.getInputFormJob(jobtask, new JobTaskExecuteInfo()); reader = new java.io.BufferedReader(new java.io.InputStreamReader(in)); String aa = null; while ((aa = reader.readLine()) != null) { System.out.println(aa); } } catch (Exception ex) { ex.printStackTrace(); } finally { if (in != null) IOUtils.closeStream(in); if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } }
Example 12
Project: eclipse.jdt.core-master File: NullConsoleReader.java View source code |
/** * Continuously reads events that are coming from the event queue. */ protected void readerLoop() { java.io.BufferedReader bufferedInput = new java.io.BufferedReader(new java.io.InputStreamReader(this.input)); try { int read = 0; while (!this.isStopping && read != -1) { read = bufferedInput.read(); } } catch (java.io.IOException e) { } }
Example 13
Project: groovy-eclipse-master File: NullConsoleReader.java View source code |
/** * Continuously reads events that are coming from the event queue. */ protected void readerLoop() { java.io.BufferedReader bufferedInput = new java.io.BufferedReader(new java.io.InputStreamReader(this.input)); try { int read = 0; while (!this.isStopping && read != -1) { read = bufferedInput.read(); } } catch (java.io.IOException e) { } }
Example 14
Project: jinhe-tss-master File: TestDownloadServlet.java View source code |
public static void testDownload() { while (true) { try { java.net.URL url = new java.net.URL("http://localhost:8088/cms/download.fun?id=881&seqNo=3"); java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection(); conn.connect(); java.io.InputStream in = conn.getInputStream(); java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(in)); String currentLine = ""; String totalString = ""; while ((currentLine = reader.readLine()) != null) { totalString += currentLine + "\n"; } in.close(); reader.close(); System.out.println(count++); Thread.sleep(100); } catch (Exception e) { e.printStackTrace(); } } }
Example 15
Project: 3380-GAS-App-master File: GetJsonTask.java View source code |
protected String doInBackground(URL... urls) { InputStream dataStream; StringBuilder response = new StringBuilder(); try { dataStream = urls[0].openStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(dataStream)); int cp; while ((cp = rd.read()) != -1) { response.append((char) cp); } return response.toString(); } catch (IOException e) { e.printStackTrace(); return null; } }
Example 16
Project: AlgoDS-master File: ABProblem1000.java View source code |
public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String s = bufferedReader.readLine(); int a = Integer.parseInt(s.split(" ")[0]); int b = Integer.parseInt(s.split(" ")[1]); PrintWriter writer = new PrintWriter(System.out); writer.write(a + b + ""); writer.flush(); writer.close(); }
Example 17
Project: Amigo-master File: A.java View source code |
public static String loadAsset(Context context) { try { InputStream is = context.getAssets().open("a.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = reader.readLine(); is.close(); return line; } catch (Exception e) { e.printStackTrace(); } return "Loading Error"; }
Example 18
Project: android-google-spreadsheets-api-master File: AssetsFileReader.java View source code |
public String assetFileContents(final String fileName) throws IOException { StringBuilder text = new StringBuilder(); InputStream fileStream = this.getClass().getClassLoader().getResourceAsStream("assets/" + fileName); BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream)); String line; while ((line = reader.readLine()) != null) { text.append(line); } return text.toString(); }
Example 19
Project: AndroidTutorialForBeginners-master File: Operations.java View source code |
// this method convert any stream to string public static String ConvertInputToStringNoChange(InputStream inputStream) { BufferedReader bureader = new BufferedReader(new InputStreamReader(inputStream)); String line; String linereultcal = ""; try { while ((line = bureader.readLine()) != null) { linereultcal += line; } inputStream.close(); } catch (Exception ex) { } return linereultcal; }
Example 20
Project: asr-tsp-master File: Test.java View source code |
public static void main(String[] argv) { BufferedReader entree = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Entrez un message:"); do { try { String tosend = entree.readLine(); } catch (EOFException eof) { System.out.println("Test"); } catch (IOException e) { e.printStackTrace(); } } while (true); }
Example 21
Project: BansheeCore-master File: IOUtils.java View source code |
public static String getStringFromStream(InputStream stream) throws IOException { StringBuilder builder = new StringBuilder(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(stream)); String temp; while ((temp = br.readLine()) != null) { builder.append(temp); } } finally { if (br != null) br.close(); } return builder.toString(); }
Example 22
Project: c2g-master File: BaseJsonTestCase.java View source code |
public String readFile(String path) throws IOException { InputStream is = this.getClass().getClassLoader().getResourceAsStream(path); BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); String inputLine; StringBuilder data = new StringBuilder(); while ((inputLine = in.readLine()) != null) { data.append(inputLine); } return data.toString(); }
Example 23
Project: claudia-master File: DiskUtils.java View source code |
public static String readFile(String path, String parentPath) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(parentPath, path)))); StringBuffer ruleFile = new StringBuffer(); String actualString; while ((actualString = reader.readLine()) != null) { ruleFile.append(actualString); } return ruleFile.toString(); }
Example 24
Project: clojure-maven-plugin-master File: ResourceTest.java View source code |
@Test public void okJar() throws IOException { String bip = "/test/build-info.properties"; InputStream s = getClass().getResourceAsStream(bip); Assert.assertNotNull(s); InputStreamReader sr = new InputStreamReader(s); BufferedReader bsr = new BufferedReader(sr); String line; try { while ((line = bsr.readLine()) != null) { System.out.println(line); } } finally { bsr.close(); } }
Example 25
Project: codeine-master File: RequestBodyReader.java View source code |
public String readBody(HttpServletRequest request) { if (body != null) { return body; } try { StringBuilder status = new StringBuilder(); BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { status.append(inputLine); } in.close(); body = status.toString(); } catch (IOException e) { throw new RuntimeException(e); } return body; }
Example 26
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 27
Project: CoreNLP-master File: AnnotatedTextReaderTest.java View source code |
public void testParse() { try { String text = "I am going to be in <LOC> Italy </LOC> sometime, soon. Specifically in <LOC> Tuscany </LOC> ."; Set<String> labels = new HashSet<String>(); labels.add("LOC"); System.out.println(AnnotatedTextReader.parseFile(new BufferedReader(new StringReader(text)), labels, null, true, "")); } catch (Exception e) { e.printStackTrace(); } }
Example 28
Project: CyanWool-master File: ConsoleThread.java View source code |
@Override public void run() { // Console... BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (running) { // Maybe... try { String line = reader.readLine(); server.getCommandManager().dispatchCommand(server.getConsoleCommandSender(), line); } catch (IOException ex) { ex.printStackTrace(); } } }
Example 29
Project: Desktop-master File: IOTools.java View source code |
public static final String getStringFromStream(InputStream is, String charsetName) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(is, charsetName)); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line + System.getProperty("line.separator")); } br.close(); return sb.toString(); }
Example 30
Project: detective-master File: ServerRunner.java View source code |
public static void main(String args[]) { try { Process p = Runtime.getRuntime().exec("java -jar /Users/bglcorp/git/detective/core/src/main/resources/seleniumserver/selenium-server-standalone-2.42.2.jar -timeout=20 -browserTimeout=60"); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = reader.readLine(); while (line != null) { System.out.println(line); line = reader.readLine(); } } catch (IOException e1) { } catch (InterruptedException e2) { } System.out.println("finished."); }
Example 31
Project: Docear-master File: IOTools.java View source code |
public static final String getStringFromStream(InputStream is, String charsetName) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(is, charsetName)); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line + System.getProperty("line.separator")); } br.close(); return sb.toString(); }
Example 32
Project: DragonGoApp-master File: Answer.java View source code |
public void get(BufferedReader in) throws IOException { String s = in.readLine(); String CodeString = s.substring(0, 3); Code = Integer.parseInt(CodeString); Text = s.substring(4); if (s.charAt(3) == '-') { while (true) { s = in.readLine(); if (s.startsWith(CodeString)) { Text = Text + "\n" + s.substring(4); break; } Text = Text + "\n" + s; } } }
Example 33
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 34
Project: eclipse-commons-master File: ProcessUtils.java View source code |
/** * Runs a process synchronously described by the given process builder and * processes the lines of its output with the given output processor. */ public static Process runProcess(ProcessBuilder processBuilder, OutputProcessor outputProcessor) throws IOException, InterruptedException { Process process = processBuilder.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream())); String line; while ((line = reader.readLine()) != null) { if (outputProcessor != null) { outputProcessor.processOutput(line); } } process.waitFor(); return process; }
Example 35
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 36
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 37
Project: Java-AI-Book-Code-master File: RunExternal.java View source code |
public static void main(String argv[]) { try { String line; Process p = Runtime.getRuntime().exec("echo \"thhe dogg brked\" | /usr/local/bin/aspell -a list"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close(); } catch (Exception err) { err.printStackTrace(); } }
Example 38
Project: javapassion-master File: HundredNames3.java View source code |
public static void main(String[] args) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String name = ""; //gets the users' name try { System.out.print("Enter name: "); name = reader.readLine(); } catch (Exception e) { System.out.println("Invalid input"); System.exit(0); } //fore loop that prints the name one hundred times for (int counter = 0; counter < 100; counter++) { System.out.println(name); } }
Example 39
Project: java_practical_semantic_web-master File: RunExternal.java View source code |
public static void main(String argv[]) { try { String line; Process p = Runtime.getRuntime().exec("echo \"thhe dogg brked\" | /usr/local/bin/aspell -a list"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close(); } catch (Exception err) { err.printStackTrace(); } }
Example 40
Project: JD-Test-master File: FillUtil.java View source code |
/** * 按行读�文本文件 * * @param is * @return * @throws Exception */ public static String readTextFromFile(InputStream is) throws Exception { InputStreamReader reader = new InputStreamReader(is); BufferedReader bufferedReader = new BufferedReader(reader); StringBuffer buffer = new StringBuffer(""); String str; while ((str = bufferedReader.readLine()) != null) { buffer.append(str); buffer.append("\n"); } return buffer.toString(); }
Example 41
Project: JFOA-master File: Testclz.java View source code |
/** * @param args */ public static void main(String[] args) { try { // URL url=Testclz.class.getResource("/"); // System.out.println(url.toString()); // System.out.println(MD5.getMD5ofStr("123456").toLowerCase()); Process p = Runtime.getRuntime().exec("ipconfig"); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), "GBK")); String s; while ((s = reader.readLine()) != null) { System.out.println(s); } } catch (Exception e) { e.printStackTrace(); } }
Example 42
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 43
Project: jsf-test-master File: URLRefBase.java View source code |
protected String readInputStream(InputStream inputStream) throws IOException { StringBuilder content = new StringBuilder(); // TODO - detect charset BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String inputLine; while ((inputLine = reader.readLine()) != null) { content.append(inputLine).append('\n'); } reader.close(); return content.toString(); }
Example 44
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 45
Project: lmis-moz-mobile-master File: JsonFileReader.java View source code |
public static String readJson(Class clazz, String fileName) { InputStream in = clazz.getClassLoader().getResourceAsStream("data/" + fileName); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuffer sb = new StringBuffer(); try { String line = reader.readLine(); while (line != null) { sb.append(line); line = reader.readLine(); } } catch (IOException e) { e.printStackTrace(); } return sb.toString(); }
Example 46
Project: marytts-master File: StreamGobbler.java View source code |
public void run() { try { InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) System.out.println(type + ">" + line); } catch (IOException ioe) { ioe.printStackTrace(); } }
Example 47
Project: master-java-master File: App.java View source code |
public static void main(String[] args) throws IOException { //Console console = System.console(); System.out.println("Introduzca una cadena:"); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(isr); char[] list = reader.readLine().toCharArray(); for (int i = list.length; i > 0; --i) System.out.print(list[i - 1]); }
Example 48
Project: MCFreedomLauncher-master File: FileBasedVersionList.java View source code |
protected String getUrl(String uri) throws IOException { InputStream inputStream = getFileInputStream(uri); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder result = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { if (result.length() > 0) result.append("\n"); result.append(line); } reader.close(); return result.toString(); }
Example 49
Project: MDE-Web-Service-Front-End-master File: RegexTest.java View source code |
public static void main(String[] args) { try { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(isr); while (true) { System.out.println("\n\nEnter equation (or CTRL-C to exit): "); String equation = reader.readLine(); System.out.println(equation.matches(REGEX)); } } catch (Exception e) { System.out.println("Oh noes."); } }
Example 50
Project: MessageClassifier-master File: FReader.java View source code |
public String readFile(BufferedReader bufferedReader) { try { String file; String line; line = bufferedReader.readLine(); file = line + "\n"; while (line != null) { line = bufferedReader.readLine(); if (line != null) { file = file + line + "\n"; } } return file; } catch (Exception e) { System.out.println("file raeding error"); } return null; }
Example 51
Project: Minecraft-Server-Mod-master File: OThreadCommandReader.java View source code |
@Override public void run() { BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(System.in)); String str = null; try { // hMod: Parse all console commands while ((!server.g) && ((str = localBufferedReader.readLine()) != null)) if (!etc.getInstance().parseConsoleCommand(str, server)) server.a(str, server); } catch (IOException localIOException) { localIOException.printStackTrace(); } }
Example 52
Project: MoKitchen-master File: DedicatedServerCommandThread.java View source code |
public void run() { BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); String s; try { while (!this.server.isServerStopped() && this.server.isServerRunning() && (s = bufferedreader.readLine()) != null) { this.server.addPendingCommand(s, this.server); } } catch (IOException ioexception) { ioexception.printStackTrace(); } }
Example 53
Project: mtgox-mini-bots-master File: DefaultConsole.java View source code |
public char[] readPassword(boolean echoInput) { try { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(isr); String result = in.readLine(); in.close(); isr.close(); return result.toCharArray(); } catch (IOException e) { throw new ParameterException(e); } }
Example 54
Project: muJava-master File: DefaultConsole.java View source code |
public char[] readPassword(boolean echoInput) { try { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(isr); String result = in.readLine(); in.close(); isr.close(); return result.toCharArray(); } catch (IOException e) { throw new ParameterException(e); } }
Example 55
Project: MyCC98-master File: StreamUtils.java View source code |
public static String Stream2String(InputStream stream) { try { BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "utf-8")); StringBuilder builder = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { builder.append(line); } return builder.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } }
Example 56
Project: NanoPond-master File: ResourcesLib.java View source code |
public static CharSequence openRawTextFile(Resources resources, int id) throws IOException { StringBuilder result = new StringBuilder(); try (InputStream ins = resources.openRawResource(id); BufferedReader reader = new BufferedReader(new InputStreamReader(ins))) { String line; while ((line = reader.readLine()) != null) { result.append(line + "\n"); } } return result; }
Example 57
Project: netty-cookbook-master File: TCPServer.java View source code |
public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while (true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); System.out.println("Received: " + clientSentence); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } //welcomeSocket.close(); }
Example 58
Project: NewAndroidTwitter-master File: StringUtil.java View source code |
public static String streamToString(InputStream is) throws IOException { String str = ""; if (is != null) { StringBuilder sb = new StringBuilder(); String line; try { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); while ((line = reader.readLine()) != null) { sb.append(line); } reader.close(); } finally { is.close(); } str = sb.toString(); } return str; }
Example 59
Project: News-Android-App-master File: URLConnectionReader.java View source code |
public static String getText(String url) throws Exception { URL website = new URL(url); URLConnection connection = website.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder(); String inputLine; while ((inputLine = in.readLine()) != null) response.append(inputLine); in.close(); return response.toString(); }
Example 60
Project: newspaper-batch-event-framework-master File: Utils.java View source code |
/** * Utility method to read an inputstream to a hadoop text * * @param inputStream * * @return * @throws java.io.IOException */ public static Text asText(InputStream inputStream) throws IOException { StringBuilder builder = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } reader.close(); return new Text(builder.toString()); }
Example 61
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 62
Project: PalletTown-master File: UrlUtil.java View source code |
public static String openUrl(String address) { String response = ""; URL url; try { url = new URL(address); try { URLConnection conn = url.openConnection(); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); response = br.readLine(); // System.out.println(response); br.close(); } catch (IOException e) { e.printStackTrace(); } } catch (MalformedURLException e) { e.printStackTrace(); } return response == null ? "" : response; }
Example 63
Project: pitest-master File: FileUtil.java View source code |
public static String readToString(final InputStream is) throws java.io.IOException { final StringBuilder fileData = new StringBuilder(1000); final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { final String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); buf = new char[1024]; } reader.close(); return fileData.toString(); }
Example 64
Project: platform_sdk-master File: Lib2.java View source code |
public static String getContent() { InputStream input = Lib2.class.getResourceAsStream("Lib2.txt"); if (input == null) { return "FAILED TO FIND Lib2.txt"; } BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); return reader.readLine(); } catch (IOException e) { } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { } } } return "FAILED TO READ CONTENT"; }
Example 65
Project: PlotSquared-master File: HttpUtil.java View source code |
public static String readUrl(String urlString) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(urlString).openStream()))) { StringBuilder buffer = new StringBuilder(); int read; char[] chars = new char[1024]; while ((read = reader.read(chars)) != -1) { buffer.append(chars, 0, read); } return buffer.toString(); } catch (IOException e) { if (Settings.DEBUG) { e.printStackTrace(); } } return null; }
Example 66
Project: PocketMonstersOnline-master File: StreamReader.java View source code |
@Override public void run() { try { InputStreamReader isr = new InputStreamReader(m_stream); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { System.out.println(m_streamName + ">" + line); } } catch (Exception e) { e.printStackTrace(); } }
Example 67
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 68
Project: Priki-master File: FileUtils.java View source code |
public String readFile(String file) throws IOException { InputStream in = this.getClass().getResource(file).openStream(); InputStreamReader inRead = new InputStreamReader(in); BufferedReader reader = new BufferedReader(inRead); StringBuilder builder = new StringBuilder(); String temp; while ((temp = reader.readLine()) != null) { builder.append(temp); } reader.close(); inRead.close(); in.close(); return builder.toString(); }
Example 69
Project: quickblox-android-sdk-master File: AssetsUtils.java View source code |
public static String getJsonAsString(String filename, Context context) throws IOException { AssetManager manager = context.getAssets(); StringBuilder buf = new StringBuilder(); InputStream json = manager.open(filename); BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8")); String str; while ((str = in.readLine()) != null) { buf.append(str); } in.close(); return buf.toString(); }
Example 70
Project: radrails-master File: AbstractProfileOutputParser.java View source code |
protected List<String> getLines(Reader reader) { List<String> lines = new ArrayList<String>(); try { BufferedReader buffered = new BufferedReader(reader); String line = null; while ((line = buffered.readLine()) != null) { lines.add(line); } } catch (IOException e) { e.printStackTrace(); } return lines; }
Example 71
Project: Rel-master File: ClientConnection.java View source code |
protected void obtainInitialServerResponse() throws IOException { initialServerResponse = new StringBuffer(); String r; final BufferedReader input = new BufferedReader(new InputStreamReader(getServerResponseInputStream())); while ((r = input.readLine()) != null) { if (r.equals("<EOT>")) break; else if (!r.equals("Ok.")) { initialServerResponse.append(r); initialServerResponse.append('\n'); } } }
Example 72
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 73
Project: ruby-type-inference-master File: SignatureClient.java View source code |
public static void main(String[] args) throws IOException { String serverAddress = JOptionPane.showInputDialog("Enter IP Address of a machine that is\n" + "running the date service on port 9090:"); Socket s = new Socket(serverAddress, 9090); BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream())); String answer = input.readLine(); JOptionPane.showMessageDialog(null, answer); System.exit(0); }
Example 74
Project: SAPJamSampleCode-master File: JamNetworkResult.java View source code |
public JSONObject toJson() throws IOException { JSONObject jsonResult = null; BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); if (bufferedReader != null) { String resultStr = ""; String line; while ((line = bufferedReader.readLine()) != null) { resultStr += line; } bufferedReader.close(); System.out.println(" JSON response: '" + resultStr + "'"); jsonResult = new JSONObject(resultStr); } return jsonResult; }
Example 75
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 76
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 77
Project: sneo-master File: ConsoleBlocker.java View source code |
public static void block(String message) { try { Thread.sleep(2000); } catch (InterruptedException e1) { } BufferedReader r = null; try { r = new BufferedReader(new InputStreamReader(System.in)); System.out.println(message); r.readLine(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (r != null) { r.close(); } } catch (IOException e) { } } }
Example 78
Project: Solr-Advert-master File: BrandsLoader.java View source code |
public static List<Brand> load(InputStream in) throws IOException { List<Brand> brands = new ArrayList<Brand>(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; while ((line = reader.readLine()) != null) { Brand brand = new Brand(); brand.setName(line); brands.add(brand); } reader.close(); return brands; }
Example 79
Project: sparc-master File: DefaultConsole.java View source code |
public char[] readPassword(boolean echoInput) { try { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(isr); String result = in.readLine(); in.close(); isr.close(); return result.toCharArray(); } catch (IOException e) { throw new ParameterException(e); } }
Example 80
Project: Stanford-NLP-master File: AnnotatedTextReaderTest.java View source code |
public void testParse() { try { String text = "I am going to be in <LOC> Italy </LOC> sometime, soon. Specifically in <LOC> Tuscany </LOC> ."; Set<String> labels = new HashSet<String>(); labels.add("LOC"); System.out.println(AnnotatedTextReader.parseFile(new BufferedReader(new StringReader(text)), labels, null, true, "")); } catch (Exception e) { e.printStackTrace(); } }
Example 81
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 82
Project: tc-ansible-runner-master File: TestLogReader.java View source code |
public static Playbook getPlaybook(String filename) { AnsibleOutputProcessor logProcessor = new AnsibleOutputProcessor(); Playbook result = null; try (BufferedReader br = new BufferedReader(new InputStreamReader(TestLogReader.class.getResourceAsStream(filename)))) { String strLine = ""; while ((strLine = br.readLine()) != null) { logProcessor.onLine(strLine); } result = logProcessor.finish(); } catch (Exception e) { throw new RuntimeException(e); } return result; }
Example 83
Project: teiid-samples-master File: FileFilterUtil.java View source code |
public static void main(String[] args) throws IOException { File file = new File("time_log"); FileInputStream fis = new FileInputStream(file); //Construct BufferedReader from InputStreamReader BufferedReader br = new BufferedReader(new InputStreamReader(fis)); String line = null; while ((line = br.readLine()) != null) { if (line.startsWith("Deserialize")) { System.out.println(line); } } br.close(); }
Example 84
Project: testng_samples-master File: DataProviders.java View source code |
@DataProvider public static Iterator<Object[]> loadUserFromFile() throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(DataProviders.class.getResourceAsStream("/user.data"))); List<Object[]> userData = new ArrayList<Object[]>(); String line = in.readLine(); while (line != null) { userData.add(line.split(";")); line = in.readLine(); } in.close(); return userData.iterator(); }
Example 85
Project: TheMinecraft-master File: DedicatedServerCommandThread.java View source code |
public void run() { BufferedReader var1 = new BufferedReader(new InputStreamReader(System.in)); String var2; try { while (!this.server.isServerStopped() && this.server.isServerRunning() && (var2 = var1.readLine()) != null) { this.server.addPendingCommand(var2, this.server); } } catch (IOException var4) { var4.printStackTrace(); } }
Example 86
Project: trimou-master File: PathTemplateLocatorTest.java View source code |
protected String read(Reader reader) throws IOException { Checker.checkArgumentNotNull(reader); BufferedReader bufferedReader = new BufferedReader(reader); StringBuilder text = new StringBuilder(); int character = bufferedReader.read(); while (character != -1) { text.append((char) character); character = bufferedReader.read(); } return text.toString(); }
Example 87
Project: vesta-id-generator-master File: VestaServer.java View source code |
public static void main(String[] args) throws IOException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/vesta-server-main.xml"); context.start(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (!"exit".equals(br.readLine())) try { Thread.sleep(60000); } catch (InterruptedException e) { e.printStackTrace(); } ; }
Example 88
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 89
Project: zendserver-sdk-java-master File: CSVLoader.java View source code |
public String[][] load(InputStream in) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(in)); List<String[]> result = new ArrayList<String[]>(); String line; while ((line = br.readLine()) != null) { //$NON-NLS-1$ result.add(line.split(",")); } return result.toArray(new String[result.size()][]); }
Example 90
Project: zh-solr-se-master File: StreamConsumer.java View source code |
public void run() { try { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { System.out.println(streamLabel + ">" + line); } } catch (IOException ioe) { ioe.printStackTrace(); } }
Example 91
Project: CloudStack-archive-master File: EncryptionSecretKeySender.java View source code |
public static void main(String args[]) { try { // Create a socket to the host String hostname = "localhost"; int port = 8097; if (args.length == 2) { hostname = args[0]; port = NumbersUtil.parseInt(args[1], port); } InetAddress addr = InetAddress.getByName(hostname); Socket socket = new Socket(addr, port); PrintWriter out = new PrintWriter(socket.getOutputStream(), true); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); java.io.BufferedReader stdin = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); String validationWord = "cloudnine"; String validationInput = ""; while (!validationWord.equals(validationInput)) { System.out.print("Enter Validation Word:"); validationInput = stdin.readLine(); System.out.println(); } System.out.print("Enter Secret Key:"); String input = stdin.readLine(); if (input != null) { out.println(input); } } catch (Exception e) { System.out.print("Exception while sending secret key " + e); } }
Example 92
Project: android-libcore64-master File: BufferedReaderTest.java View source code |
/** * @tests java.io.BufferedReader#mark(int) */ public void test_markI() throws IOException { // Test for method void java.io.BufferedReader.mark(int) char[] buf = null; br = new BufferedReader(new Support_StringReader(testString)); br.skip(500); br.mark(1000); br.skip(250); br.reset(); buf = new char[testString.length()]; br.read(buf, 0, 500); assertTrue("Failed to set mark properly", testString.substring(500, 1000).equals(new String(buf, 0, 500))); try { br = new BufferedReader(new Support_StringReader(testString), 800); br.skip(500); br.mark(250); br.read(buf, 0, 1000); br.reset(); fail("Failed to invalidate mark properly"); } catch (IOException x) { } char[] chars = new char[256]; for (int i = 0; i < 256; i++) chars[i] = (char) i; Reader in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(14); in.read(new char[14], 0, 14); in.reset(); assertTrue("Wrong chars", in.read() == (char) 6 && in.read() == (char) 7); in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(8); in.skip(7); in.reset(); assertTrue("Wrong chars 2", in.read() == (char) 6 && in.read() == (char) 7); BufferedReader br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); char[] carray = new char[3]; int result = br.read(carray); assertEquals(3, result); assertEquals("Assert 0:", '0', carray[0]); assertEquals("Assert 1:", '1', carray[1]); assertEquals("Assert 2:", '2', carray[2]); assertEquals("Assert 3:", '3', br.read()); br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); carray = new char[4]; result = br.read(carray); assertEquals("Assert 4:", 4, result); assertEquals("Assert 5:", '0', carray[0]); assertEquals("Assert 6:", '1', carray[1]); assertEquals("Assert 7:", '2', carray[2]); assertEquals("Assert 8:", '3', carray[3]); assertEquals("Assert 9:", '4', br.read()); assertEquals("Assert 10:", -1, br.read()); BufferedReader reader = new BufferedReader(new StringReader("01234")); reader.mark(Integer.MAX_VALUE); reader.read(); reader.close(); }
Example 93
Project: android-sdk-sources-for-api-level-23-master File: BufferedReaderTest.java View source code |
/** * @tests java.io.BufferedReader#mark(int) */ public void test_markI() throws IOException { // Test for method void java.io.BufferedReader.mark(int) char[] buf = null; br = new BufferedReader(new Support_StringReader(testString)); br.skip(500); br.mark(1000); br.skip(250); br.reset(); buf = new char[testString.length()]; br.read(buf, 0, 500); assertTrue("Failed to set mark properly", testString.substring(500, 1000).equals(new String(buf, 0, 500))); try { br = new BufferedReader(new Support_StringReader(testString), 800); br.skip(500); br.mark(250); br.read(buf, 0, 1000); br.reset(); fail("Failed to invalidate mark properly"); } catch (IOException x) { } char[] chars = new char[256]; for (int i = 0; i < 256; i++) chars[i] = (char) i; Reader in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(14); in.read(new char[14], 0, 14); in.reset(); assertTrue("Wrong chars", in.read() == (char) 6 && in.read() == (char) 7); in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(8); in.skip(7); in.reset(); assertTrue("Wrong chars 2", in.read() == (char) 6 && in.read() == (char) 7); BufferedReader br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); char[] carray = new char[3]; int result = br.read(carray); assertEquals(3, result); assertEquals("Assert 0:", '0', carray[0]); assertEquals("Assert 1:", '1', carray[1]); assertEquals("Assert 2:", '2', carray[2]); assertEquals("Assert 3:", '3', br.read()); br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); carray = new char[4]; result = br.read(carray); assertEquals("Assert 4:", 4, result); assertEquals("Assert 5:", '0', carray[0]); assertEquals("Assert 6:", '1', carray[1]); assertEquals("Assert 7:", '2', carray[2]); assertEquals("Assert 8:", '3', carray[3]); assertEquals("Assert 9:", '4', br.read()); assertEquals("Assert 10:", -1, br.read()); BufferedReader reader = new BufferedReader(new StringReader("01234")); reader.mark(Integer.MAX_VALUE); reader.read(); reader.close(); }
Example 94
Project: ARTPart-master File: BufferedReaderTest.java View source code |
/** * @tests java.io.BufferedReader#mark(int) */ public void test_markI() throws IOException { // Test for method void java.io.BufferedReader.mark(int) char[] buf = null; br = new BufferedReader(new Support_StringReader(testString)); br.skip(500); br.mark(1000); br.skip(250); br.reset(); buf = new char[testString.length()]; br.read(buf, 0, 500); assertTrue("Failed to set mark properly", testString.substring(500, 1000).equals(new String(buf, 0, 500))); try { br = new BufferedReader(new Support_StringReader(testString), 800); br.skip(500); br.mark(250); br.read(buf, 0, 1000); br.reset(); fail("Failed to invalidate mark properly"); } catch (IOException x) { } char[] chars = new char[256]; for (int i = 0; i < 256; i++) chars[i] = (char) i; Reader in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(14); in.read(new char[14], 0, 14); in.reset(); assertTrue("Wrong chars", in.read() == (char) 6 && in.read() == (char) 7); in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(8); in.skip(7); in.reset(); assertTrue("Wrong chars 2", in.read() == (char) 6 && in.read() == (char) 7); BufferedReader br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); char[] carray = new char[3]; int result = br.read(carray); assertEquals(3, result); assertEquals("Assert 0:", '0', carray[0]); assertEquals("Assert 1:", '1', carray[1]); assertEquals("Assert 2:", '2', carray[2]); assertEquals("Assert 3:", '3', br.read()); br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); carray = new char[4]; result = br.read(carray); assertEquals("Assert 4:", 4, result); assertEquals("Assert 5:", '0', carray[0]); assertEquals("Assert 6:", '1', carray[1]); assertEquals("Assert 7:", '2', carray[2]); assertEquals("Assert 8:", '3', carray[3]); assertEquals("Assert 9:", '4', br.read()); assertEquals("Assert 10:", -1, br.read()); BufferedReader reader = new BufferedReader(new StringReader("01234")); reader.mark(Integer.MAX_VALUE); reader.read(); reader.close(); }
Example 95
Project: robovm-master File: BufferedReaderTest.java View source code |
/** * @tests java.io.BufferedReader#mark(int) */ public void test_markI() throws IOException { // Test for method void java.io.BufferedReader.mark(int) char[] buf = null; br = new BufferedReader(new Support_StringReader(testString)); br.skip(500); br.mark(1000); br.skip(250); br.reset(); buf = new char[testString.length()]; br.read(buf, 0, 500); assertTrue("Failed to set mark properly", testString.substring(500, 1000).equals(new String(buf, 0, 500))); try { br = new BufferedReader(new Support_StringReader(testString), 800); br.skip(500); br.mark(250); br.read(buf, 0, 1000); br.reset(); fail("Failed to invalidate mark properly"); } catch (IOException x) { } char[] chars = new char[256]; for (int i = 0; i < 256; i++) chars[i] = (char) i; Reader in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(14); in.read(new char[14], 0, 14); in.reset(); assertTrue("Wrong chars", in.read() == (char) 6 && in.read() == (char) 7); in = new BufferedReader(new Support_StringReader(new String(chars)), 12); in.skip(6); in.mark(8); in.skip(7); in.reset(); assertTrue("Wrong chars 2", in.read() == (char) 6 && in.read() == (char) 7); BufferedReader br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); char[] carray = new char[3]; int result = br.read(carray); assertEquals(3, result); assertEquals("Assert 0:", '0', carray[0]); assertEquals("Assert 1:", '1', carray[1]); assertEquals("Assert 2:", '2', carray[2]); assertEquals("Assert 3:", '3', br.read()); br = new BufferedReader(new StringReader("01234"), 2); br.mark(3); carray = new char[4]; result = br.read(carray); assertEquals("Assert 4:", 4, result); assertEquals("Assert 5:", '0', carray[0]); assertEquals("Assert 6:", '1', carray[1]); assertEquals("Assert 7:", '2', carray[2]); assertEquals("Assert 8:", '3', carray[3]); assertEquals("Assert 9:", '4', br.read()); assertEquals("Assert 10:", -1, br.read()); BufferedReader reader = new BufferedReader(new StringReader("01234")); reader.mark(Integer.MAX_VALUE); reader.read(); reader.close(); }
Example 96
Project: abstools-master File: StreamReaderThread.java View source code |
public void run() { try { if (in != null) { writer = new StringWriter(); InputStreamReader isr = new InputStreamReader(in); BufferedReader br = new BufferedReader(isr); String line = null; //Read the lines of the buffered reader. while ((line = br.readLine()) != null) writer.write(line + "\n"); br.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } }
Example 97
Project: AbstractViewAdapter-master File: Templates.java View source code |
public String read(String path) { InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream(path)); BufferedReader bufferedReader = new BufferedReader(reader); StringBuilder builder = new StringBuilder(); String line = null; do { try { if (line != null) { builder.append("\n"); } line = bufferedReader.readLine(); if (line != null) { builder.append(line); } } catch (IOException e) { e.printStackTrace(); break; } } while (line != null); return builder.toString(); }
Example 98
Project: adastra-java-master File: FileUtils.java View source code |
public static List<String> readLines(String filename) { List<String> lines = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader(new InputStreamReader((FileUtils.class.getClassLoader().getResourceAsStream(filename)))); try { String line = reader.readLine(); while (line != null) { lines.add(line); line = reader.readLine(); } } catch (IOException e) { e.printStackTrace(); } finally { reader.close(); } } catch (IOException e) { throw new RuntimeException(e); } return lines; }
Example 99
Project: Advanced-Logon-Editor-master File: FileReader.java View source code |
protected static List<String> readFile(Path file) { assert FileUtil.control(file); List<String> sb = new LinkedList<>(); String line = null; Charset charset = Charset.defaultCharset(); try (BufferedReader reader = Files.newBufferedReader(file, charset)) { while ((line = reader.readLine()) != null) { sb.add(line); } reader.close(); } catch (IOException e) { return null; } return sb; }
Example 100
Project: AIDR-master File: MySpreadsheetIntegration.java View source code |
public static void main(String[] args) throws Exception { String[] row = null; URL stockURL = new URL("http://localhost:8888/tornadotweets.csv"); BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream())); CSVReader csvReader = new CSVReader(in); List content = csvReader.readAll(); for (Object object : content) { row = (String[]) object; System.out.println(row[0] + " # " + row[1] + " # " + row[2]); } csvReader.close(); }
Example 101
Project: AIM-master File: Command.java View source code |
@Override public void run() { try { BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (Exception e) { throw new RuntimeException(e); } }