Results 1 to 2 of 2
  1. #1
    kcananda is offline Member
    Join Date
    Aug 2012
    Rep Power

    Default java read n write to file with unicode text

    i write a code to read a file with text written in utf-8 and write in another file...but always it write whole text in ?????????

    import java.nio.charset.Charset;

    class Readnwrite {
    public static void main(String args[]) throws Exception {
    Charset ch = Charset.forName("UTF-8");
    BufferedReader bufReader = new BufferedReader(new InputStreamReader(new FileInputStream("abc.txt"),ch));
    FileWriter fstream = new FileWriter("out.txt");
    BufferedWriter out = new BufferedWriter(fstream);
    String s;
    while((s = bufReader.readLine()) != null) {

    What is the problem ....................

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: java read n write to file with unicode text

    Does the Sys.out print the correct text?

    How are you checking the file?

    What does the original file contain?

    If you aren't concerned with actually using the stuff read in then just read and write bytes using an InputStream and an OutputStream, that way you can ignore the character set entirely.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. how to read and write ods file in java
    By sanjeev4343 in forum New To Java
    Replies: 1
    Last Post: 07-08-2012, 09:12 PM
  2. Text read and write between *.txt file and *.xls file
    By lemontree45 in forum New To Java
    Replies: 6
    Last Post: 08-12-2011, 02:08 AM
  3. Read/edit/Write text file
    By Graupner1000 in forum New To Java
    Replies: 17
    Last Post: 08-25-2010, 02:04 PM
  4. Write unicode into file
    By vata2999 in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 03:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts