Re: How to specify encoding in Java?
From: Raymond DeCampo (rdecampo_at_spam-I-am-not.twcny.rr.com)
Date: 01/25/04
- Next message: del cecchi: "Re: Mars Rover Not Responding - Update - NASA Makes Contact With Mars Rover"
- Previous message: Raymond DeCampo: "Re: Q: Java source and directory structure - 'standard way' ?"
- In reply to: Konrad Den Ende: "How to specify encoding in Java?"
- Next in thread: Konrad Den Ende: "Re: How to specify encoding in Java?"
- Reply: Konrad Den Ende: "Re: How to specify encoding in Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jan 2004 03:08:51 GMT
Konrad Den Ende wrote:
> I've been looking around and i've been given some hints but
> i simply can't get to the bottom of it. How do i specify the
> character encoding for reading text froma file?
>
Open the file as normal with an InputStream. Then use InputStreamReader
to wrap the stream, passing the desired encoding.
E.g., to open a file in UTF-16:
InputStream is = new BufferedInputStream(
new FileInputStream("unicode.txt"));
Reader reader = new InputStreamReader(is, "UTF-16");
See the javadoc for more information on which encodings are supported
and fancier ways of specifying them.
Ray
- Next message: del cecchi: "Re: Mars Rover Not Responding - Update - NASA Makes Contact With Mars Rover"
- Previous message: Raymond DeCampo: "Re: Q: Java source and directory structure - 'standard way' ?"
- In reply to: Konrad Den Ende: "How to specify encoding in Java?"
- Next in thread: Konrad Den Ende: "Re: How to specify encoding in Java?"
- Reply: Konrad Den Ende: "Re: How to specify encoding in Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|