• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with charset while writing String to File

 
Brian Nguyen
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to write a method that writes a String into a file:
--------------------------------------------------------------
private synchronized void saveTicketsToFile(String inTickets){
try{
String fullPathFilename = "D:/learn/e_ticket.dat";
BufferedWriter writer = new BufferedWriter(new FileWriter(fullPathFilename));
writer.write(inTickets);
writer.flush();
writer.close();
} catch (Exception e){
System.out.println("ERROR: " + e);
e.printStackTrace();
}

--------------------------------------------------------------
However, everytime I run this program, I always have the following error:
ERROR: java.lang.IllegalArgumentException: Null charset name

Here is the stack trace that I have:
at java.nio.charset.Charset.lookup(Charset.java:376)
at java.nio.charset.Charset.isSupported(Charset.java:405)
at sun.nio.cs.StreamEncoder.forOutputStreamWriter(StreamEncoder.java:68)
at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:93)
at java.io.FileWriter.<init>(FileWriter.java:61)


So I am wondering if anyone could explain why I have that problem with Charset?
Thank you very much for your help!
Brian

[ October 11, 2004: Message edited by: Brian Nguyen ]
[ October 11, 2004: Message edited by: Brian Nguyen ]
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never seen anything like that. Are you doing anything strange with locale settings? Will your code work on a different computer? Your JDK or JRE may be screwed up.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic