Training work stream lO

package Suchas;
 import java.io. * ;

public class FileIO 
{
    public FileIO(String str)
     {
         File f = new File("data.txt");
         try 
         {
             File file = new File("data.txt");
             FileWriter fw = new FileWriter(file);
             BufferedWriter bw = new BufferedWriter(fw);
            bw.write(str);
             bw.close();
         } catch (IOException e)
         {
            e.printStackTrace ();
        }
    }
    public static void main(String[] args) 
    {
         Str String = " 12345abcdef @ #% & * Software Engineering " ;
          new new File (str);
 
     }
 
 }
package Suchas;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 public class Filedemo
 {
     public Filedemo()
     {
         File f = new File("data.txt");
             try {
                 BufferedReader br = new BufferedReader(new FileReader(f));
                String str = br.readLine();
                 System.out.println(str);
                 br.close();
            } catch (FileNotFoundException e) 
             {
                 e.printStackTrace ();
             } catch (IOException e) 
             {
                 e.printStackTrace ();
             }    
     }
     public static void main(String[] args) 
     {
         new Filedemo();
 
     }
 
 }

 

Guess you like

Origin www.cnblogs.com/LesslsMoreRIght/p/11031720.html