BufferedInputStream input = null;
BufferedOutputStream output = null;
try{
input = new BufferedInputStream(new FileInputStream("data.txt"));
output = new BufferedOutputStream(new FileOutputStream("newdata.txt"));
for(int i = input.read(); i != -1; i = input.read()){
output.write(i);
System.out.println();
}
//Flush in case the buffer doesn't fill up when done
output.flush();
}catch (IOException ex){
System.out.println();
}finally {
try{
if (input != null){
input.close(); //Closes both the
}
if (output != null){
output.close(); //Closes both the
}
}catch (IOException ex){
System.out.println(ex);
}
}