BufferedReader close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for BufferedReader close method.

This code example shows how to use the following methods:close
      pPartition = PhysicalPartition.parsePhysicalPartitionString(physicalParitionParameter, "_");
    } 
 
    boolean startWin = Boolean.valueOf(startWinStr);
 
    BufferedReader in = new BufferedReader(new FileReader(fileStr));
 
    try 
    { 
      //PhysicalPartition pPartition = new PhysicalPartition(physicalPartitionId); 
      // TODO this should actually use DbusEventBufferAppendable (DDSDBUS-78) 
      DbusEventBuffer buf = (DbusEventBuffer)_eventBuffer.getDbusEventBufferAppendable(pPartition);
      if(buf == null)
        throw new RequestProcessingException("cannot find buffer for ph. partion " + pPartition);
 
      if ((buf.getMinScn() < 0) && (buf.getPrevScn() < 0)) buf.start(0);
 
      try 
      { 
        DbusEventsStatisticsCollector statsCollector = _relay.getInBoundStatsCollectors().getStatsCollector(pPartition.toSimpleString());

9
CodeRank
This code example shows how to use the following methods:close
		} 
	} 
 
	public void close() throws IOException { 
		if (input != null)
			input.close();
 
		start = end = -1;
		current = size = 0;
	} 
 
	public boolean ready() { 
		try { 
			return current < end || input.ready();
		} catch (IOException e) {
			throw new OIOException("Error in ready", e);
		} 
	} 
 
	public int length() { 
8
CodeRank
This code example shows how to use the following methods:close, readLine, sleep
		try { 
			logger.debug("KeyValueStore waiting for clients...");	 
			Socket clientSocket = serverSocket.accept();
			logger.debug("KeyValueStore client connected..."); 
			BufferedWriter os = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
			BufferedReader is = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
			String input = is.readLine();
			logger.debug("KeyValueStore received input: {}", input);
			if (input.split("\\s+").length == 2) {
				input = input.split("\\s+")[1];	// "GET deft" => "deft"
			} 
			int sleep = 250;
			if (input != null) {
				logger.debug("KeyValueStore server sleeps " + sleep + "ms..." );
				try { 
					Thread.sleep(sleep);
				} catch (InterruptedException e) {
					e.printStackTrace();
				} 
				logger.debug("KeyValueStore woke up..."); 

8
CodeRank
This code example shows how to use the following methods:close, readLine
  } 
 
  private void assertReadText(Path f) throws Exception {
    InputStream ir = StreamUtils.inputStream(f);
    InputStreamReader in = new InputStreamReader(ir, StandardCharsets.UTF_8);
    BufferedReader r = new BufferedReader(in);
    String line = r.readLine();
    assertEquals("Wrong text found in "+f.getFileName(), TEXT, line);
    r.close();
  } 
   
  @Override 
  @Before 
  public void setUp() throws Exception {
    super.setUp(); 
    testDir = getWorkDir().resolve("ContentSourceTest");
    IOUtils.rm(testDir);
    Files.createDirectory(testDir);
  } 
 
8
CodeRank
This code example shows how to use the following methods:close, readLine
    Path[] outputFiles = FileUtil.stat2Paths(
                           getFileSystem().listStatus(getOutputDir(), 
                           new Utils.OutputFileUtils.OutputFilesFilter())); 
    assertEquals(1, outputFiles.length);
    InputStream is = getFileSystem().open(outputFiles[0]);
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    assertEquals("0\tb a", reader.readLine());
    assertNull(reader.readLine());
    reader.close();
  } 
 
  public void testComplexNameWithRegex() throws Exception { 
    OutputStream os = getFileSystem().create(new Path(getInputDir(),
        "text.txt")); 
    Writer wr = new OutputStreamWriter(os);
    wr.write("b a\n");
    wr.close();
 
    JobConf conf = createJobConf();
    conf.setJobName("name \\Evalue]");
8
CodeRank
This code example shows how to use the following methods:close, readLine, sleep
        try { 
            URL url = new URL("http://localhost:9003/Application/writeChunks2");
            URLConnection connection = url.openConnection();
            connection.setConnectTimeout(5000);
            connection.setReadTimeout(5000);
            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line = reader.readLine();
            if (line != null)
                result = line.trim();
        } 
        catch (IOException e) {
        } 
        finally { 
            if (reader != null) {
                try { 
                    reader.close();
                } 
                catch (IOException e) {
                } 
            } 

8
CodeRank
This code example shows how to use the following methods:close, readLine
    File success = new File(outdir.getAbsolutePath() + File.separator
        + "_SUCCESS"); 
    Assert.assertTrue(success.exists());
 
    FileInputStream fis = new FileInputStream(result);
    BufferedReader br = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
    String line = br.readLine();
    Assert.assertTrue(("1 44" + TAB + "2").equals(line));
    line = br.readLine();
 
    Assert.assertTrue(("3 44" + TAB + "1").equals(line));
    line = br.readLine();
 
    Assert.assertTrue(("4 44" + TAB + "1").equals(line));
 
    br.close();
 
  } 
 
  /** 
   * Create simple log file 
8
CodeRank
This code example shows how to use the following methods:close, readLine
 
            findQuery = em.createQuery("Select p from UserInfo p where p.userId=\"Shahid\"");
            findQuery.getResultList(); 
            System.setOut(printStream);
 
            br = new BufferedReader(new FileReader("showQuery.log"));
            isFileEmpty = br.readLine() == null;
            Assert.assertEquals(isFileEmpty, true);
 
        } 
        catch (Exception e)
        { 
            logger.info(e.getMessage());
        } 
        finally 
        { 
            br.close();
        } 
    } 
 

8
CodeRank
This code example shows how to use the following methods:close, readLine
        String host = null;
        File forwardHostConf = new File(FORWARD_HOST_CONF);
        if (forwardHostConf.isFile()) {
            BufferedReader hostReader = null;
            try { 
                hostReader = new BufferedReader(new FileReader(forwardHostConf));
                host = hostReader.readLine();
                Log.v(LOGTAG, "read forward host from file: " + host);
            } catch (IOException ioe) {
                Log.v(LOGTAG, "cannot read forward host from file", ioe);
            } finally { 
                if (hostReader != null) {
                    try { 
                        hostReader.close();
                    } catch (IOException ioe) {
                        // burn!!! 
                    } 
                } 
            } 
        } 
7
CodeRank
This code example shows how to use the following methods:close, readLine
    public static String readOneLine(String fname) {
        BufferedReader br;
        String line = null;
 
        try { 
            br = new BufferedReader(new FileReader(fname), 512);
            try { 
                line = br.readLine();
            } finally { 
                br.close();
            } 
        } catch (Exception e) {
            Log.e(TAG, "IO Exception when reading /sys/ file", e);
        } 
        return line;
    } 
 
    public static boolean writeOneLine(String fname, String value) {
        try { 
            FileWriter fw = new FileWriter(fname);
7
CodeRank

Related BufferedReader close Questions & Answers:

Other BufferedReader close Examples

19:	    if (reader != null) {
20:	      try {
21:	        reader.close();
22:	      } catch (IOException e) {
23:	        e.printStackTrace();

Read More

close Method Overview
Closes the stream and releases any system resources associated with it.
See Code Examples for other Java 8 BufferedReader Methods: