IT. Expert System.

Java basics

available()


The java.io.FileInputStream.available() method returns number of remaining bytes that can be read from this input stream without blocking by the next method call for this input stream. The next method call can also be the another thread.

Syntax:
public int available()


Example:

import java.io.IOException;
import java.io.FileInputStream;

public class FileInputStreamDemo {
   public static void main(String[] args) throws IOException {
      
      FileInputStream fis = null;
      int available = 0;
      int i=0;
      
      try{
         // create new file input stream
         fis = new FileInputStream("C://test.txt");
         
         // read till the end of the stream
         while((i=fis.read())!=-1)
         {
            // available bytes
            available = fis.available();
            
            // convert integer to character
            char c = (char)i;
            
            // prints
            System.out.print("Available: "+available);
            System.out.println("; Read: "+c);
         }
      }catch(Exception ex){
         // if an I/O error occurs
         ex.printStackTrace();
      }finally{
         
         // releases all system resources from the streams
         if(fis!=null)
         {
            fis.close();
         }
      }
   }
}


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 97 / 159176601. Delta: 0.00158 с