Home Java Example Java Io Writing ISO Latin-1 Encoded Data in Java
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Writing ISO Latin-1 Encoded Data in Java

Advertisement
In this program, you will see how to write content in a file in the ISO Latin-1 character set.

Writing ISO Latin-1 Encoded Data in Java

     

Introducton

In this program, you will see how to write content in a file in the ISO Latin-1 character set. This program takes a file name, if the given file exists then writes text into the file otherwise shows the message : "File does not exists.".

out.write( )

This is the method is used to write text in the specified file in the ISO Latin-1 character set. Here, the specified string is "Welcome to RoseIndia.Net" which has to be written into the file.

Here is the code of the program : 

import java.io.*;

 
public class WriteEncodedLatin{
 
  
public static void main(String[] args)throws IOException{
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  System.out.print("Enter File name : ");
 
  
String str = in.readLine();
 
 
File file = new File(str);
 
  
if(!file.exists())
 {
 
 
System.out.println("File does not exist");
 
  
System.exit(0);
  }
  else
  {
  try{
  BufferedWriter out = new BufferedWriter(new OutputStreamWriter
    (
new FileOutputStream(file),"8859_1"));
  out.write("WelCome to RoseIndia.Net");
 
 
out.close();
  
  
System.out.println("Written Process Completed");
 
  
}
  
  
catch(UnsupportedEncodingException ue){

    System.out.println("Not supported : ");
 
  
}
  
  
catch(IOException e){
 
 
System.out.println(e.getMessage());
  
  
}
 
 
}
 
 
}

  }


Output of the Program:

C:\nisha>javac WriteEncodedLatin.java

C:\nisha>java WriteEncodedLatin
Enter File name : Filterfile.txt
Written Process Completed

C:\nisha>

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 17, 2007

Related Tutorials

Ask Questions?    Discuss: Writing ISO Latin-1 Encoded Data in Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Coralie
November 1, 2011
rIYlfkLTHesm

The purchases I make are entirely based on these atircles.
DMCA.com