KickJava   Java API By Example, From Geeks To Geeks.

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

java.io
Class PushbackReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by java.io.PushbackReader
All Implemented Interfaces:
Closeable, Readable
See Also:
Top Examples, Source Code

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


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


[604]Read the file from the beginning
By venki568 { at } rediffmail { dot } com on 2004/01/12 10:43:23  Rate
/* NOTE: My aim is to read the file from the beginning when counter should decrement. */ 
  
  
  
  
 import java.io.*; 
 import java.util.*; 
 import java.lang.Object.*; 
 import java.io.ObjectStreamException; 
 import java.io.OptionalDataException; 
  
  
  
 public class arrstr  
  {  
   static String s=null; 
   public static void main ( String args [  ]  )  throws IOException 
    {  
       try 
        {   
         String widget=null; 
         int count=3; 
         boolean flag=true; 
         boolean eof=true; 
         File f = new File ( args [ 0 ]  ) ; 
         FileReader fr = new FileReader ( args [ 0 ]  ) ; 
         BufferedReader br = new BufferedReader ( fr, ( int ) f.length (  )  ) ; 
         s=br.readLine (  ) ; 
   
      while (  ( s != null )  &&  ( count < =3 )  )  
       {  
        do  
          {  
              StringTokenizer st=new StringTokenizer ( s,";" ) ; 
              while ( st.hasMoreTokens (  )  )  
               {  
                 widget=st.nextToken (  ) ; 
                if (  ( count==3 && widget.equalsIgnoreCase ( "SSTEdObj" )  )  || ( count==3 && widget.equalsIgnoreCase ( "SCButObj" )  )  ||  ( count==3 && widget.equalsIgnoreCase ( "SLBoxObj" )  )  ||  
                    ( count==3 && widget.equalsIgnoreCase ( "STButObj" )  )  || ( count==3 && widget.equalsIgnoreCase ( "TArea" )  )  )  
                 {   
                  System.out.println ( widget ) ;                
                 }  
                 
               }  s=br.readLine (  ) ; 
               
            } while ( !eof ) ;  
      }  
      // br.close (  ) ; 
       // fr.close (  ) ;        
      
    /* FileReader fr1 = new FileReader ( args [ 0 ]  ) ; 
         BufferedReader br1 = new BufferedReader ( fr1, ( int ) f.length (  )  ) ; 
         s=br1.readLine (  ) ; 
      while (  ( s != null )  )  
       {  
        do  
          {  
              StringTokenizer st=new StringTokenizer ( s,";" ) ; 
              while ( st.hasMoreTokens (  )  )  
               {  
                 widget=st.nextToken (  ) ; 
                if (  (  widget.equalsIgnoreCase ( "Panel" )  )  
                    
                 {   
                  System.out.println ( widget ) ;                
                 }  
                 
               }  s=br.readLine (  ) ; 
               
            } while ( !eof ) ;  
      }  
        br.close (  ) ; 
        fr.close (  ) ;        
     */
      
     int ln= ( int )  f.length (  ) ; 
     System.out.println ( ln ) ; 
      br.mark ( -10 ) ; 
      br.reset (  ) ; 
      
     s=br.readLine (  ) ; 
      System.out.println ( " s value "+s ) ; 
      br.close (  ) ; 
        fr.close (  ) ;        
     }  
     //try block close 
     
       catch ( NullPointerException e )  
       {  System.out.println ( " error" ) ;  }         
     }          
    
  } 


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


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


public PushbackReader(Reader in,
                      int size)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


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


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


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


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


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


public void unread(char[] cbuf)
            throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void unread(char[] cbuf,
                   int off,
                   int len)
            throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void unread(int c)
            throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags