PrintStream Format1() Example

Writes a formatted string to this output stream


PrintStreamclass Format1() method example. This example shows you how to use Format1() method.This methodWrites a formatted string to this output stream using the specified format string and arguments.

Here is the code:-

/**
 * @Program that Writes a formatted string to this output stream using the 
 * specified format string and arguments.
 * Format1.java 
 * Author:-RoseIndia Team
 * Date:-10-Jun-2008
 */
import java.io.*;
import java.util.*;

public class Format1 {

    public static void main(String[] argsthrows IOException {
       Locale l=new Locale("English");
       String s="rose";
        //Creating FileOutputStream object
        FileOutputStream out = new FileOutputStream("text.txt");
        FileInputStream fin = new FileInputStream("text.txt");
        //Creating PrintStream object
        PrintStream ps = new PrintStream(out);
        // Writes a formatted string to this output stream
        ps.format(s, new String(""));
        System.out.println("Formatted string : ");
        System.out.println((char)fin.read());
         System.out.println((char)fin.read());
         System.out.println((char)fin.read());
         System.out.println((char)fin.read());
       
           }
    }

Output of the Program
 Formatted string :
r
o
s
e

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

HOME | COPYRIGHT | CONTACT US