Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.PrintStream;
- public class WriteAdress {
- public void citesteFisier() throws IOException{
- int x=0;
- BufferedReader in=new BufferedReader(new FileReader("readme.txt"));
- String s,s2=new String();
- while((s=in.readLine())!=null){
- s2+=s+"\n";
- x=x+1;
- }
- in.close();
- System.out.println(s2);
- System.out.println("sunt "+x+" randuri");
- }
- public void printAddress() throws IOException {
- FileOutputStream fOut=new FileOutputStream("readme.txt");
- PrintStream ps=new PrintStream(fOut);
- ps.println( "Name: Ioan Iacob" );
- ps.println( "Town: Tirgu Mures" );
- ps.println( "Country: Romania" );
- ps.close();
- fOut.close();
- }
- public static void main( String argv[] ) throws IOException {
- WriteAdress wa = new WriteAdress();
- wa.printAddress();
- wa.citesteFisier();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement