PrintStream Write1() Example

Writes the specified byte to this stream.


PrintStreamclass Write1() method example. This example shows you how to use Write1() method.This method Writes the specified byte to this stream.

Here is the code:-

/**
 * @Program that Writes the specified byte to this stream.
 * Write1.java 
 * Author:-RoseIndia Team
 * Date:-10-Jun-2008
 */
import java.io.*;

public class Write1 {

    public static void main(String[] argsthrows IOException {
        int d = 123;
        //Creating FileOutputStream object
        FileOutputStream out = new FileOutputStream("text.txt");
        FileInputStream fin = new FileInputStream("text.txt");
        //Creating PrintStream object
        PrintStream ps = new PrintStream(out);
        //Writes the specified byte to this stream.
        ps.write(d);
        System.out.println("Bytes are : ");
        System.out.println(fin.read());
                   }
    }

Output of the Program
 Bytes are :
123

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US