KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > io > InputStreamReader

java.io
Class InputStreamReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.InputStreamReader
All Implemented Interfaces:
Closeable, Readable
Direct Known Subclasses:
FileReader
See Also:
Top Examples, Source Code, BufferedReader, InputStream, Charset

public void close()
           throws IOException
See Also:
Reader, Closeable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getEncoding()
See Also:
Charset, InputStreamReader(InputStream, String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public InputStreamReader(InputStream in)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[130]Read from system console line by line
By ollie { at } appsaspeers { dot } com on 2004/09/09 13:42:04  Rate
// ... process your input stream 
 String resultStr = ""; 
 InputStream is = new InputStream ( System.in ) ; 
 InputStreamReader isr = new InputStreamReader ( is ) ; 
 java.io.BufferedReader br = new java.io.BufferedReader ( isr ) ;   
        
 System.out.println ( "Reading stream" ) ; 
 do  {  
     try  {  
   line =  ( String )  br.readLine (  ) ; 
      }  catch  ( IOException e )   {  
    System.out.println ( "IO Exception on Buffered Read" ) ; 
      } ; 
     resultStr += line + "\r\n"; 
   }  while  ( line != null ) ; 
         
  System.out.println ( "resultStr" ) ; 
 


[806]_
By art { at } paladin { dot } cx on 2004/06/15 16:06:36  Rate
    try 
      {  
       String result = ""; 
  
  
       InputStreamReader reader  = new InputStreamReader ( System.in ) ;  
       java.io.BufferedReader br = new java.io.BufferedReader ( reader ) ;    
               
       System.out.println ( "Reading stream  ( type 'quit' to exit ) " ) ;  
  
  
       while (  true  )  
        {   
         String line =  ( String )  br.readLine (  ) ;  
  
  
         if (  line.equals ( "quit" )  )  break; 
           result += line + "\n";  
        }  
  
  
       System.out.println ( result ) ;   
      }  
     catch (  Exception e  )  
      {  
       System.out.println (  "An Exception has occured" + e.getMessage (  )   ) ; 
      } 


public InputStreamReader(InputStream in,
                         String charsetName)
                  throws UnsupportedEncodingException
See Also:
charset
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public InputStreamReader(InputStream in,
                         Charset cs)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[503]Specify Charset for an input stream
By Anonymous on 2003/11/10 14:49:37  Rate
BufferedReader br = new BufferedReader 
     ( new InputStreamReader 
     ( new FileInputStream  ( resource_file ) , "ISO-8859-1" )  ) ;


[1200]_
By Anonymous on 2004/12/17 09:35:36  Rate
If you use this constructor, you had to make sure that you do not pass a NULL Charset, Otherwise a null Charset will result in an exception.

[1975]Recognizes more invalid characters
By Anonymous on 2008/08/01 10:16:54  Rate
Changed the character set used to read in the data to "ISO-8859-1" - this set recognizes more invalid characters 
  
  
 BufferedReader br = new BufferedReader  
       (  new InputStreamReader  
       (  new FileInputStream   (  resource_file  )  , Charset.forName ( "ISO-8859-1" )   )    )  ; 
 


public InputStreamReader(InputStream in,
                         CharsetDecoder dec)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void mark(int readAheadLimit)
          throws IOException
See Also:
Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean markSupported()
See Also:
Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int read()
         throws IOException
See Also:
Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int read(char[] cbuf,
                int offset,
                int length)
         throws IOException
See Also:
Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean ready()
              throws IOException
See Also:
Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void reset()
           throws IOException
See Also:
Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public long skip(long n)
          throws IOException
See Also:
IllegalArgumentException, Reader
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags