Results 1 to 3 of 3
Thread: String file and carriage returns
- 04-16-2010, 10:54 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 59
- Rep Power
- 0
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.
- 04-17-2010, 01:02 AM #2
Member
- Join Date
- Apr 2010
- Posts
- 59
- Rep Power
- 0
****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.
-
Thanks, I have banned him and removed his posts.
Similar Threads
-
Waiting for a carriage return
By Ebodee in forum New To JavaReplies: 1Last Post: 02-12-2010, 03:46 AM -
NetworkInterface returns only ports that are up
By dogbert in forum NetworkingReplies: 0Last Post: 10-13-2009, 05:12 PM -
Checking if string contains only tabs/spaces/newlines/carriage returns
By Singing Boyo in forum New To JavaReplies: 3Last Post: 08-20-2009, 03:57 PM -
What's the need for co-variant returns ?
By ajeeb in forum New To JavaReplies: 0Last Post: 03-23-2009, 09:56 AM -
New line or Carriage Return through FileWriter
By johnt in forum New To JavaReplies: 2Last Post: 05-20-2007, 09:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks