Reading ISO Latin-1 Encoded Data in Java

In this section, you will learn about ISO Latin-1 Encoded Data. The ISO, it stands for International Organization for Standardization.

Reading ISO Latin-1 Encoded Data in Java

In this section, you will learn about ISO Latin-1 Encoded Data. The ISO, it stands for International Organization for Standardization.

Reading ISO Latin-1 Encoded Data in Java

Reading ISO Latin-1 Encoded Data in Java

     

Introduction

  The ISO stands for Organization for International Standardization. ISO is a standard characters set. The ISO Latin-1 is a supper set of the ASCII character set. It is the character set for Western European languages and an 8-bit encoding scheme in which every encoded character takes exactly 8 bits. The ISO-8859-1 standard also known as "Latin alphabet No. 1". 

Here, you will see how to use the ISO 8859-1 character set. This program takes the file name by user. If the given file exists then this program reads it's contents otherwise shows the appropriate message like: "File does not exist".

BufferedReader i = 
new BufferedReader(new InputStreamReader(new FileInputStream(file),"8859_1"));


Above  code has been written to create the instance of the BufferedReader class using InputStreamReader and FileInputStream classes to create buffer for reading contents from the specified file in standard ISO-1 format using the "8859-1", mentioned in the above line of the code.

Here is the code of program:

import java.io.*;
 


public class ReadEncodedLatin{
 
  
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{
 
    
BufferedReader i = new BufferedReader(new InputStreamReader
  (
new FileInputStream(file),"8859_1"));
 
  
String str1 = i.readLine();
 
 
System.out.println("File Text : "+ str1);
  System.out.println("Reading Process Completly Successfully.");
 
  
}
 
 
catch(UnsupportedEncodingException ue){
  
  
System.out.println("Not supported : ");
 
  
}
 
 
catch(IOException e){
 
  
System.out.println(e.getMessage());
 
  
}
 
 
}
 
 
}
 

}


Output of the Program:

C:\nisha>javac ReadEncodedLatin.java

C:\nisha>java ReadEncodedLatin
Enter File name : Filterfile.txt
File Text : WelCome to RoseIndia.Net
Reading Process Completly Successfully.

C:\nisha>

 Download this example.