Monday, 19 October 2015

Writing into the file using BufferedOutputStream 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",true);
BufferedOutputStream bout = new BufferedOutputStream(fout,1024);
char ch;
while((ch = (char)dis.read())!='*'){
bout.write(ch);
}
bout.close();
}
}


output:-
Sr.Performance engineer
Sai Nagendra Bhavani Prasad
Java Profiles
APM Tools
*

Text file contents:-
Sr.Performance engineer
Sai Nagendra Bhavani Prasad
Java Profiles
APM Tools

No comments:

Post a Comment