Home Java Example Java Io Writing ISO Latin-1 Encoded Data in Java



Writing ISO Latin-1 Encoded Data in Java
Posted on: April 17, 2007 at 12:00 AM
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.

Related Tags for Writing ISO Latin-1 Encoded Data in Java:
javacfiletextdatavinameintthismessageidwriteshowiftexexampleexistsprogramtoencoderamexamwsshexteilitisonotwiseinnomntsagejesstsagemehowintoprodoxaxampsssasoessatkishaivmplcodcodesaxtwisvaxissrithshoavstatihatexilatinpleplprodeogro


More Tutorials from this section

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

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.