Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I store and retrieve Unicode or Double Byte data in a file using the java.io libraries?

0
Posted

How can I store and retrieve Unicode or Double Byte data in a file using the java.io libraries?

0

Location: http://www.jguru.com/faq/view.jsp?EID=70736 Created: Jun 9, 2000 Modified: 2001-08-18 17:27:31.039 Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by Tian Hao (http://www.jguru.com/guru/viewbio.jsp?EID=56209 Java supports a number of encodings for use with InputStreamReaders and OutputStreamWriters. By using these classes, it’s easy to read and write Unicode or any other supported encodings. Here’s some code that writes a Unicode string to a file and then reads it back in. Please note that the sample’s emphasis is on Unicode functionality — obviously more care should be taken with exceptions and file closings in a production program: import java.io.*; public class WRUni { public static void main(String[] args) { FileOutputStream fos = null; OutputStreamWriter osw = null; BufferedWriter bw = null; FileInputStream fis = null; InputStreamReader isr = null; BufferedReader br = null; String sUni = null; try { // write a UniCode s

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123