28 March 2011

ReadFile Encoding UTF-8 - java

ReadFile Encoding UTF-8 - java

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReadUTF8Data {
    private static final String FILE_ENCODE = "UTF-8";
    public static void main(String[] args) {
        String data = null;
        BufferedReader dataIns = null;
        String file = "";
        try {
            dataIns = new BufferedReader(new InputStreamReader(
            new FileInputStream(file), FILE_ENCODE));
            
            while ((data = dataIns.readLine()) != null) {
                System.out.println("Line 1 :" + data);
            }
            dataIns.close();
            dataIns = null;
            } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Blog by Chagridsada Boonthus | http://chagridsada.blogspot.com/