import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class InputStreamNNOutputStream {
public static void main(String[] args) throws IOException {
try {
byte bWrite[] = {1,2,3,4,5,6};
OutputStream os = new FileOutputStream("output.txt");
for (int i = 0; i < bWrite.length; i++) {
os.write(bWrite[i]);
}
os.close();
InputStream is = new FileInputStream("output.txt");
int size = is.available();
for (int j = 0; j < size; j++) {
System.out.print((char)is.read() + " - ");
}
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
-----------------------------------------------------------------------------------------------------------------
// OUTPUT :
//The below code would create file test.txt and would write given numbers in binary format.
No comments:
Post a Comment