Tabnine Logo
BufferedReader.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.io.BufferedReader
constructor

Best Java code snippets using java.io.BufferedReader.<init> (Showing top 20 results out of 98,289)

Refine searchRefine arrow

  • BufferedReader.readLine
  • InputStreamReader.<init>
  • BufferedReader.close
  • PrintStream.println
  • FileReader.<init>
canonical example by Tabnine

public void postRequest(String urlStr, String jsonBodyStr) throws IOException {
  URL url = new URL(urlStr);
  HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
  httpURLConnection.setDoOutput(true);
  httpURLConnection.setRequestMethod("POST");
  httpURLConnection.setRequestProperty("Content-Type", "application/json");
  try (OutputStream outputStream = httpURLConnection.getOutputStream()) { 
   outputStream.write(jsonBodyStr.getBytes());
   outputStream.flush();
  }
  if (httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
    try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()))) {
      String line;
      while ((line = bufferedReader.readLine()) != null) {
        // ... do something with line
      }
    }
  } else {
    // ... do something with unsuccessful response
  }
}
canonical example by Tabnine

public void readAllLines(InputStream in) throws IOException {
 try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in))) {
  String line;
  while ((line = bufferedReader.readLine()) != null) {
   // ... do something with line
  }
 }
}
origin: stackoverflow.com

 try {
  BufferedReader br = new BufferedReader(new FileReader(inputFile));
  ...
  ...
} catch (Exception e) {
  e.printStacktrace();
}
origin: stackoverflow.com

 try(BufferedReader br = new BufferedReader(new FileReader(file))) {
  for(String line; (line = br.readLine()) != null; ) {
    // process the line.
  }
  // line is not visible here.
}
origin: stackoverflow.com

 String contentType = connection.getHeaderField("Content-Type");
String charset = null;

for (String param : contentType.replace(" ", "").split(";")) {
  if (param.startsWith("charset=")) {
    charset = param.split("=", 2)[1];
    break;
  }
}

if (charset != null) {
  try (BufferedReader reader = new BufferedReader(new InputStreamReader(response, charset))) {
    for (String line; (line = reader.readLine()) != null;) {
      // ... System.out.println(line) ?
    }
  }
} else {
  // It's likely binary content, use InputStream/OutputStream.
}
origin: eugenp/tutorials

  private String bodyToString(InputStream body) throws IOException {
    StringBuilder builder = new StringBuilder();
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(body, StandardCharsets.UTF_8));
    String line = bufferedReader.readLine();
    while (line != null) {
      builder.append(line).append(System.lineSeparator());
      line = bufferedReader.readLine();
    }
    bufferedReader.close();
    return builder.toString();
  }
}
origin: stackoverflow.com

 BufferedReader br = new BufferedReader(new FileReader("file.txt"));
try {
  StringBuilder sb = new StringBuilder();
  String line = br.readLine();

  while (line != null) {
    sb.append(line);
    sb.append(System.lineSeparator());
    line = br.readLine();
  }
  String everything = sb.toString();
} finally {
  br.close();
}
origin: stackoverflow.com

String result = new BufferedReader(new InputStreamReader(inputStream))
.lines().collect(Collectors.joining("\n"));
origin: stanfordnlp/CoreNLP

public static void main(String[] args) throws Exception {
 BufferedReader br = new BufferedReader(new FileReader("/tmp/acstats"));
 Prior p = new Prior(br);
 HashSet<String> hs = new HashSet<String>();
 hs.add("workshopname");
 //hs.add("workshopacronym");
 double d = p.get(hs);
 System.out.println("d is " + d);
}
origin: checkstyle/checkstyle

void method() throws Exception {
  final String fileName = "Test";
  final BufferedReader br = new BufferedReader(new InputStreamReader(
      new FileInputStream(fileName), StandardCharsets.UTF_8));
  try {
  } finally {
    br.close();
  }
}
origin: google/guava

private static List<String> readUsingJava(String input, int chunk) throws IOException {
 BufferedReader r = new BufferedReader(getChunkedReader(input, chunk));
 List<String> lines = Lists.newArrayList();
 String line;
 while ((line = r.readLine()) != null) {
  lines.add(line);
 }
 r.close();
 return lines;
}
origin: stanfordnlp/CoreNLP

private void readRawBytes(String fileName) throws IOException {
 BufferedReader in = new BufferedReader(new FileReader(fileName));
 StringBuffer buf = new StringBuffer();
 int c;
 while ((c = in.read()) >= 0)
  buf.append((char) c);
 mRawBuffer = buf.toString();
 // System.out.println(mRawBuffer);
 in.close();
}
origin: apache/incubator-dubbo

/**
 * read lines.
 *
 * @param is input stream.
 * @return lines.
 * @throws IOException
 */
public static String[] readLines(InputStream is) throws IOException {
  List<String> lines = new ArrayList<String>();
  BufferedReader reader = new BufferedReader(new InputStreamReader(is));
  try {
    String line;
    while ((line = reader.readLine()) != null) {
      lines.add(line);
    }
    return lines.toArray(new String[0]);
  } finally {
    reader.close();
  }
}
origin: stackoverflow.com

 BufferedReader br = new BufferedReader(new FileReader(path));
try {
  return br.readLine();
} finally {
  br.close();
}
origin: stackoverflow.com

 String newLine = System.getProperty("line.separator");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder result = new StringBuilder();
String line; boolean flag = false;
while ((line = reader.readLine()) != null) {
  result.append(flag? newLine: "").append(line);
  flag = true;
}
return result.toString();
origin: stackoverflow.com

 private static String getValue(Part part) throws IOException {
  BufferedReader reader = new BufferedReader(new InputStreamReader(part.getInputStream(), "UTF-8"));
  StringBuilder value = new StringBuilder();
  char[] buffer = new char[1024];
  for (int length = 0; (length = reader.read(buffer)) > 0;) {
    value.append(buffer, 0, length);
  }
  return value.toString();
}
origin: stackoverflow.com

 try (BufferedReader br = new BufferedReader(new FileReader(file))) {
  String line;
  while ((line = br.readLine()) != null) {
    // process the line.
  }
}
origin: stanfordnlp/CoreNLP

/**
 * For testing only.
 */
public static void main(String[] args) throws IOException {
 Tokenizer<String> t = new LexerTokenizer(new JFlexDummyLexer((Reader) null), new BufferedReader(new FileReader(args[0])));
 while (t.hasNext()) {
  System.out.println("token " + t.next());
 }
}
origin: stanfordnlp/CoreNLP

public void readGrammar(String filename) {
 try {
  FileReader fin = new FileReader(filename);
  BufferedReader bin = new BufferedReader(fin);
  readGrammar(bin);
  bin.close();
  fin.close();
 } catch (IOException e) {
  throw new RuntimeIOException(e);
 }
}

origin: commons-io/commons-io

@Test
public void testFilteringBufferedReader() throws Exception {
  final String encoding = "UTF-8";
  final String fileName = "LineIterator-Filter-test.txt";
  final File testFile = new File(getTestDirectory(), fileName);
  final List<String> lines = createLinesFile(testFile, encoding, 9);
  final Reader reader = new BufferedReader(new FileReader(testFile));
  this.testFiltering(lines, reader);
}
java.ioBufferedReader<init>

Javadoc

Constructs a new BufferedReader, providing in with a buffer of 8192 characters.

Popular methods of BufferedReader

  • readLine
    Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carr
  • close
    Closes this reader. This implementation closes the buffered source reader and releases the buffer. N
  • read
    Reads characters into a portion of an array. This method implements the general contract of the corr
  • lines
  • ready
    Tells whether this stream is ready to be read. A buffered character stream is ready if the buffer is
  • reset
    Resets the stream to the most recent mark.
  • mark
    Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the
  • skip
    Skips characters.
  • markSupported
    Tells whether this stream supports the mark() operation, which it does.
  • checkNotClosed
  • chompNewline
    Peeks at the next input character, refilling the buffer if necessary. If this character is a newline
  • fillBuf
    Populates the buffer with data. It is an error to call this method when the buffer still contains da
  • chompNewline,
  • fillBuf,
  • isClosed,
  • maybeSwallowLF,
  • readChar,
  • fill,
  • ensureOpen,
  • read1

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now