Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileOutputStream;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.io.PrintStream;
  7.  
  8. public class WriteAdress {
  9.    
  10.                public void citesteFisier() throws IOException{
  11.                    int x=0;
  12.                    BufferedReader in=new BufferedReader(new FileReader("readme.txt"));
  13.                    String s,s2=new String();
  14.                    while((s=in.readLine())!=null){
  15.                        s2+=s+"\n";
  16.                    x=x+1;
  17.                }
  18.                    in.close();
  19.                    System.out.println(s2);
  20.                    System.out.println("sunt "+x+" randuri");
  21.                }
  22.  
  23.                 public void printAddress() throws IOException {
  24.                    
  25.                     FileOutputStream fOut=new FileOutputStream("readme.txt");
  26.                    
  27.                     PrintStream ps=new PrintStream(fOut);
  28.                    
  29.                     ps.println( "Name: Ioan Iacob" );
  30.  
  31.                     ps.println( "Town: Tirgu Mures" );
  32.  
  33.                     ps.println( "Country: Romania" );
  34.                    
  35.                     ps.close();
  36.                    
  37.                     fOut.close();
  38.  
  39.                 }
  40.  
  41.  
  42.  
  43.                 public static void main( String argv[] ) throws IOException {
  44.  
  45.                     WriteAdress wa = new WriteAdress();
  46.  
  47.                     wa.printAddress();
  48.  
  49.                     wa.citesteFisier();
  50.                 }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement