Java FileOutputStream write() MethodThe write(byte[] b) method of FileOutputStream class is used to write b.length bytes from the specified byte array to this file output stream. SyntaxParameterb - the data. Return ValueThis method does not return any value. ExceptionIOException - If any I/O error occurs. Example 1Output: Enter 5 byte to write into a file 23 67 65 55 45 You Enter 5 byte successfully byte that you enter into the File is 23 67 65 55 45 Example 2Output: byte's ---->23,45,67,78,98,67<--->that is write into a file<----> successfully write byte's into a file byte that you enter into the File is 23 45 67 78 98 67 Example 3Output: byte's ---->23,45,67,78,98,67<--->that is write into a file<----> successfully write byte's into a file character value of that byte's that you enter into the File is ! 7 B N Z Java FileOutputStream write(byte[] b, int off, int len) MethodThe write(byte[] b, int off, int len) method of Java FileOutputStream class is used to write data from the given maximum length(len) of the data starting from the given offset. SyntaxParameterb - The data. off - The start offset in the data. slen - The number of bytes to write. Return ValueThis method does not return a value. ExceptionIOException - If an I/O error occurs. Example 1Output: byte's ----> 23 ,45 ,67 ,78 ,98 ,67 <--->that is write into a file<----> successfully write byte's into a file---> 2 index position to 3 index position. byte that you enter into the File is 67 78 98 Example 2Output: byte's ---->23,45,67,78,98,67<--->that is write into a file<----> write byte' from 2 index position to the next 2 postion successfully write byte's into a file character value of that byte's that you enter into the File is B N Java FileOutputStream write(int b) MethodThe write(int b) method of Java FileOutputStream class is used to write the specified byte to this file output stream. SyntaxParameterb - The byte. Return ValueThis method does not return a value. ExceptionIOException - If an I/O error occurs. Example 1Output: Enter a byte to write into a file 23 you enter byte successfully byte that you enter into the File is 23 Example 2Output: Enter byte to write into a file 34 you enter byte successfully convert a byte into a character that is
Next TopicJava FileOutputStream Class
|