3:26 pm - Monday September 25, 2017

BufferedOutputStream example program for write(int b) in java

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
 * @description: BufferedOutputStream example program for write(int b) in java
 */

import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;

public class WriteByteToFile {
	public static void main(String[] args) {
		String s = "Sample.txt";
		try {
			FileOutputStream fos = new FileOutputStream(s);
			BufferedOutputStream bos = new BufferedOutputStream(fos);
			byte b = 17;
			System.out.println("Writing File");
			bos.write(b);
			System.out.println("Finished Writing File");

		} catch (FileNotFoundException fnfe) {
			System.out.println("Specified file not found" + fnfe);
		} catch (IOException io) {
			System.out.println("IOException" + io);
		}

	}
}

Output

Writing File
Finished Writing File

BACK

Filed in: Z-A All Java Codes

Comments are closed.