79.FileOutputStream in JAVA
//Byte Stream
//FileOutputStream
import java.io.*;
class FileOutputStream1
{
public static void main(String[] args) {
try{
FileOutputStream fos = new FileOutputStream("bytes.txt");
for (int i = 1; i <= 10; i++) {
fos.write(i);
//String str = "Line : " + i;
//byte arr[] = str.getBytes();
//.write(arr);
}
fos.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT:
text file : bytes.txt
1 2 3 4 5 6 7 8 9 10
Comments
Post a Comment