Monday, 19 October 2015

writing data into the file usinf FileOutputStream in java

import java.io.*;
public class First {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
DataInputStream dis = new DataInputStream(System.in);
FileOutputStream fout = new FileOutputStream("test.txt");
char ch;
while((ch = (char)dis.read())!='*'){
fout.write(ch);
}
fout.close();
}

}


Output:-
q
w
e
r
t
y
u
i
*

In text file:-
q
w
e
r
t
y
u
i

No comments:

Post a Comment