framework assets connected with the document. This method also throws an
IOException.
public void write(byte[] w)
This method composes w.length bytes from the specified
byte exhibit to the
Outputstream.
There are other imperative output streams accessible, which are as follows:
ByteArrayOutputStream
DataOutputStream
Sample Implementations:
import java.io.*;
public class Mytestfile{
public static void main(string args[]){
try{
byte bytewrite [] = {45,64,22,49,1};
OutputStream myos = new FileOutputStream(“mytest.txt”);
for(int i=0; i < bytewrite.length ; i++){
myos.write( bytewrite[x] );
}
myos.close();
InputStream myis = new FileInputStream(“mytest.txt”);
int sizex = myis.available();
for(int z=0; z< sizex; z++){
System.out.print((char)myis.read() + “ “);
}
myis.close();
}catch(IOException e){
System.out.print(“Exception Caught!”);
}
}
The above code would make a file mytest.txt and would
compose given numbers in
parallel organization. Same would be outputted to the stdout screen.
Do'stlaringiz bilan baham: