Tabnine Logo
BufferedReader.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
java.io.BufferedReader

Best Java code snippets using java.io.BufferedReader.close (Showing top 20 results out of 46,953)

Refine searchRefine arrow

  • BufferedReader.readLine
  • BufferedReader.<init>
  • InputStreamReader.<init>
  • FileReader.<init>
  • PrintStream.println
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: 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: gocd/gocd

private static StringBuilder dump(BufferedReader reader, StringBuilder builder) throws IOException {
  String line;
  while ((line = reader.readLine()) != null) {
    builder.append(line + "\n");
  }
  reader.close();
  return builder;
}
origin: stackoverflow.com

 LineNumberReader  lnr = new LineNumberReader(new FileReader(new File("File1")));
lnr.skip(Long.MAX_VALUE);
System.out.println(lnr.getLineNumber() + 1); //Add 1 because line index starts at 0
// Finally, the LineNumberReader object should be closed to prevent resource leak
lnr.close();
origin: stanfordnlp/CoreNLP

public TraditionalSimplifiedCharacterMap(String path) {
 // TODO: gzipped maps might be faster
 try {
  FileInputStream fis = new FileInputStream(path);
  InputStreamReader isr = new InputStreamReader(fis, "utf-8");
  BufferedReader br = new BufferedReader(isr);
  init(br);
  br.close();
  isr.close();
  fis.close();
 } catch (IOException e) {
  throw new RuntimeIOException(e);
 }
}
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: 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: 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: stanfordnlp/CoreNLP

protected String getLine() {
 try {
  String result = this.reader.readLine();
  if (result == null) {
   readerOpen = false;
   this.reader.close();
  }
  return result;
 } catch (IOException e) {
  throw new RuntimeIOException(e);
 }
}
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 reader = new BufferedReader(new FileReader("file.txt"));
int lines = 0;
while (reader.readLine() != null) lines++;
reader.close();
origin: google/guava

public void testNewReader() throws IOException {
 File asciiFile = getTestFile("ascii.txt");
 try {
  Files.newReader(asciiFile, null);
  fail("expected exception");
 } catch (NullPointerException expected) {
 }
 try {
  Files.newReader(null, Charsets.UTF_8);
  fail("expected exception");
 } catch (NullPointerException expected) {
 }
 BufferedReader r = Files.newReader(asciiFile, Charsets.US_ASCII);
 try {
  assertEquals(ASCII, r.readLine());
 } finally {
  r.close();
 }
}
origin: stackoverflow.com

 import java.net.*;
import java.io.*;

public class URLConnectionReader {
  public static void main(String[] args) throws Exception {
    URL yahoo = new URL("http://www.yahoo.com/");
    URLConnection yc = yahoo.openConnection();
    BufferedReader in = new BufferedReader(
                new InputStreamReader(
                yc.getInputStream()));
    String inputLine;

    while ((inputLine = in.readLine()) != null) 
      System.out.println(inputLine);
    in.close();
  }
}
origin: h2oai/h2o-2

public static void log(File file, PrintStream stream) throws Exception {
 BufferedReader reader = new BufferedReader(new FileReader(file));
 try {
  for( ;; ) {
   String line = reader.readLine();
   if( line == null ) break;
   stream.println(line);
  }
 } finally {
  reader.close();
 }
}
origin: stackoverflow.com

 InputStream responseStream = new 
  BufferedInputStream(httpUrlConnection.getInputStream());

BufferedReader responseStreamReader = 
  new BufferedReader(new InputStreamReader(responseStream));

String line = "";
StringBuilder stringBuilder = new StringBuilder();

while ((line = responseStreamReader.readLine()) != null) {
  stringBuilder.append(line).append("\n");
}
responseStreamReader.close();

String response = stringBuilder.toString();
origin: jenkinsci/jenkins

LinuxProcess(int pid) throws IOException {
  super(pid);
  BufferedReader r = new BufferedReader(new FileReader(getFile("status")));
  try {
    String line;
    while((line=r.readLine())!=null) {
      line=line.toLowerCase(Locale.ENGLISH);
      if(line.startsWith("ppid:")) {
        ppid = Integer.parseInt(line.substring(5).trim());
        break;
      }
    }
  } finally {
    r.close();
  }
  if(ppid==-1)
    throw new IOException("Failed to parse PPID from /proc/"+pid+"/status");
}
origin: stackoverflow.com

 // Open the file
FileInputStream fstream = new FileInputStream("textfile.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));

String strLine;

//Read File Line By Line
while ((strLine = br.readLine()) != null)   {
 // Print the content on the console
 System.out.println (strLine);
}

//Close the input stream
br.close();
java.ioBufferedReaderclose

Javadoc

Closes this reader. This implementation closes the buffered source reader and releases the buffer. Nothing is done if this reader has already been closed.

Popular methods of BufferedReader

  • <init>
    Creates a buffering character-input stream that uses an input buffer of the specified size.
  • readLine
    Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carr
  • 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

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Runner (org.openjdk.jmh.runner)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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