Solved

How to save a string in UTF-8 format into a txt-file?

Posted on 2006-06-28
1
256 Views
Last Modified: 2008-02-01
In my program I am going to save a string into a txt.file as follow:

...
  StringBuffer output = new StringBuffer("some text...");
  File outputFile = new File("produkt.txt");
  FileWriter out = null;
  // Open the file
  try {
    out = new FileWriter(outputFile);
   } catch (Exception e) {
     e.printStackTrace();
  }
  // Write string in to the file
  try {
  out.write(output.toString());
  out.close();
  }catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
  }
...

But how can I change the program so the file could be saved in UTF-8 format ?
0
Comment
Question by:chenwei
[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
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 30 total points
ID: 17000018
 StringBuffer output = new StringBuffer("some text...");
  File outputFile = new File("produkt.txt");
  Writer out = null;
  // Open the file
  try {
    out = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF8");
   } catch (Exception e) {
     e.printStackTrace();
  }
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache Camel - Unable to propagate JMS Header Properties between Request - Response 3 16
xampp tool 12 58
servlet filter example 37 83
jboss 7.1 start up error 1 60
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

761 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