Results 1 to 4 of 4

Thread: [Java] read and write a file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default [Java] read and write a file

    Hi,
    I have one problem; I must read a html like this;
    Qt Code:
    1. <html>
    2. <body>
    3. Hello
    4. </body>
    5. </html>
    To copy to clipboard, switch view to plain text mode 
    I read this in a string (correct?) and after I have to do some changes to it and write it on disk but in this way:
    Qt Code:
    1. <html>\n<body> ........
    To copy to clipboard, switch view to plain text mode 
    There, there's the '\n' because in the original file <body> was in another line of <html>
    How can I do this? This my code for read and write:
    Qt Code:
    1. File fin = new File(FILE_NAME);
    2. FileReader in = new FileReader(fin);
    3. istream = new BufferedReader( in );
    4. String line = null;
    5.  
    6. while ( (line = istream.readLine()) != null ) {
    7. //System.out.println(line);
    8. sb.append(line);
    9. }
    10. // here do changes on the sb
    11. String text = sb.toString();
    12. FileWriter fw = new FileWriter(new File ("out.txt") );
    13. out = new PrintWriter(fw);
    14. out.println(text);
    To copy to clipboard, switch view to plain text mode 

    Thanks,
    Last edited by mickey; 22nd June 2008 at 03:13.
    Regards

Similar Threads

  1. How can I Read Write Excel File
    By xingshaoyong in forum Qt Programming
    Replies: 6
    Last Post: 13th July 2011, 20:16
  2. structures to a file (read and write)
    By baray98 in forum Qt Programming
    Replies: 5
    Last Post: 10th February 2008, 20:12
  3. How to open a file in Read Write mode
    By merry in forum Qt Programming
    Replies: 13
    Last Post: 16th November 2007, 14:40
  4. Read \Write Excel File using Qt
    By xingshaoyong in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 22:07
  5. FSWriteFork in MAC OS to write data to a file.
    By vishal.chauhan in forum General Programming
    Replies: 5
    Last Post: 2nd July 2007, 06:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.