KickJava   Java API By Example, From Geeks To Geeks.

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

java.io
Class FileWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.OutputStreamWriter
          extended by java.io.FileWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable
See Also:
Top Examples, Source Code, FileOutputStream

public FileWriter(File file)
           throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1952]java file creation
By bharathi { dot } startrak { at } gmail { dot } com on 2008/01/31 06:40:51  Rate
1.To create an input file. 
 2.Write the content to the above file. 
 3.Then parse the file 
 4.Create new file and write the content of parsed file


public FileWriter(File file,
                  boolean append)
           throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[388]Create a text file using PrintWriter
By Anonymous on 2005/06/15 00:44:50  Rate
f = new File ( "TC.txt" ) ; 
         FileWriter fw = new FileWriter ( f,false ) ; 
     PrintWriter pw = new PrintWriter ( fw ) ; 
 


[758]Tests the double file writer
By rchjac006 { at } mail { dot } uct { dot } ac { dot } za on 2004/07/12 18:49:48  Rate
//RACHOENE JACOB  
  
  
 //This program tests the double file writer. 
 import DoubleFileWriter; 
  
  
 public class TestWriter 
  {  
   public static void main ( String [  ]  args )  
   throws java.io.IOException, java.text.ParseException 
    {  
     //Make the DoubleFileWriter object. 
     DoubleFileWriter writer = new DoubleFileWriter (  ) ; 
      
     //Open the file     
     writer.open ( "test.text" ) ; 
      
     //Write 10 numbers to the file 
     for ( int i =0; i < = 12 ; i++ )  
      {  
       writer.write ( i ) ;   
      }  
      
     //Close the file 
     writer.close (  ) ; 
    }  
  } 


public FileWriter(FileDescriptor fd)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileWriter(String fileName)
           throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileWriter(String fileName,
                  boolean append)
           throws IOException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[162]_
By Anonymous on 2005/06/15 00:43:48  Rate
//Copy a file 
 try 
  {      
    String line = null; 
    BufferedReader br = new BufferedReader ( new FileReader ( "oldFileName" )  ) ; 
    PrintWriter pr = new PrintWriter ( new BufferedWriter ( new FileWriter ( "newFileName", false )  )  ) ;       
          
    while  (  ( line = br.readLine (  )  )  != null )   {  
         pr.println ( line ) ; 
     }  
   
    br.close (  ) ;             
    br = null; 
        
    pr.close (  ) ; 
    pr = null;         
        
  }  catch  ( java.io.FileNotFoundException ex )   {  
    System.out.println ( "File '" + args [ 0 ]  + "' does not exist. " ) ;       
  }  catch  ( java.io.IOException ex )   {  
    ex.printStackTrace (  ) ; 
  }  
 

Popular Tags