DataOutputStream WriteUTF() Example

Writes a string to the underlying output stream using modified UTF-8 encoding


DataOutputStreamclass WriteUTF() method example. This example shows you how to use WriteUTF() method.This method Writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.

Here is the code:-
/**
 * @Program that Writes a string to the underlying output stream using modified
    UTF-8  encoding 
 * WriteUTF.java 
 * Author:-RoseIndia Team
 * Date:-09-jun-2008
 */
import java.io.*;
public class WriteUTF {
public static void main(String[] args)throws IOException {
String s="Girish";
FileOutputStream fos=new FileOutputStream("g.txt");    
DataOutputStream dos=new DataOutputStream(fos);
//Writes a string to the underlying output stream using modified UTF-8 encoding 
dos.writeUTF(s);
FileInputStream fis=new FileInputStream("g.txt");    
DataInputStream dis=new DataInputStream(fis);
System.out.println("String to the underlying output stream is : "+dis.readUTF());
    }
}

Output of the Program
 String to the underlying output stream is : Girish

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

HOME | COPYRIGHT | CONTACT US