Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Cool String file and carriage returns

    I have a JTEXTAREA to input some text. The input will feature carriage returns. Such as:
    Line1 <carriage return>
    Line2 <carriage return>

    However, I have some problems!

    For example when I process the text e.g. count the number of lines the computer only sees it as one line.

    When I save the text to a file (.txt format) a thin rectangle symbol is inserted for each carriage return. To my amusement(!) when I reopen the file using my program the computer recognises that I have two lines! Furthermore it prints out the text showing that there are carriage returns and none of the thin rectangle symbols!

    One way around the problem could be to save the file first and then reload the file and process the text around the saved file! However, I would rather the text file that was saved so that it does not have the thin rectangle symbols and instead shows a proper carriage return for each line. My key code" in the main program below. I am grateful for any help!!


    JTextArea area = new JTextArea();
    area.setText(x);
    area.setRows(20);
    area.setColumns(30);
    area.setEditable(true);
    area.setLineWrap(true);
    area.setWrapStyleWord(true);
    JScrollPane scrollpane = new JScrollPane(area);


    Object[] array = {new JLabel("Please edit or enter your text:"),
    scrollpane, };

    JOptionPane.showConfirmDialog(null, array, "Edit your text",
    JOptionPane.OK_CANCEL_OPTION);

    File file;
    file=savefilepicker.filesaver();

    savefilepicker.textwriter(area.getText() , file);
    //The program passes the area.getText() to save the contents to the file.

  2. #2
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Default

    ****Please be aware "www.1videotutorial.t35.com" contains a virus!! ****

    McAfee reported that it had removed a virus and cleaned it. The site did not work for me.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. Waiting for a carriage return
    By Ebodee in forum New To Java
    Replies: 1
    Last Post: 02-12-2010, 03:46 AM
  2. NetworkInterface returns only ports that are up
    By dogbert in forum Networking
    Replies: 0
    Last Post: 10-13-2009, 05:12 PM
  3. Replies: 3
    Last Post: 08-20-2009, 03:57 PM
  4. What's the need for co-variant returns ?
    By ajeeb in forum New To Java
    Replies: 0
    Last Post: 03-23-2009, 09:56 AM
  5. New line or Carriage Return through FileWriter
    By johnt in forum New To Java
    Replies: 2
    Last Post: 05-20-2007, 09:13 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
  •