?
Solved

How can I know what file's encoding when I read a file use New I/O package???

Posted on 2003-02-21
4
Medium Priority
?
220 Views
Last Modified: 2010-03-31
Hi every body,
When I use NIO (New I/O JDK1.4) to read a file's content.
How can I know exactly file's encoding (example: UTF-8, Cp1252, shift-jis ...) to choose right decoder to decode the file??
Thanks
Best regards.
Hung, Nguyen Thanh.
0
Comment
Question by:hungnguyenthanh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Venci75 earned 600 total points
ID: 7992187
For the UTF files - you can check for BOM in the beggining of the file:
http://www.unicode.org/unicode/faq/utf_bom.html#22
If your file is in XML format and its first line is like this :
<?xml version="1.0" encoding="UTF-8"?>
you can take the encoding from the line.
In all cases - there is no standard way to find the file encoding.
0
 

Author Comment

by:hungnguyenthanh
ID: 8078885
Pls help me. Thanks
0
 
LVL 9

Expert Comment

by:Venci75
ID: 8079133
???
as I have already mentioned - there is no universal way to determine the file encoding
0
 

Author Comment

by:hungnguyenthanh
ID: 8099920
But how can I recognize between two encoding file, all not unicode encoding, example: between shift-jis and ansi?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question