Home arrow static arrow Java Programming [Archive] - writing "enter" or carrage return into a txt file
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - writing "enter" or carrage return into a txt file
This topic has 2 replies on 1 page.

Posts:2
Registered: 8/3/04
writing "enter" or carrage return into a txt file  
Aug 3, 2004 8:37 AM



 
Hello, I am trying to write to a file. I am wondering how to get a carrage return into the text file. I used a for loop and type cast the ascii code into a char. the for loop goes from 0 to 127 but when the program writes to the file, none of them are a carrage return (enter). If anyone can help me that would be great. Thank you.
Here is my for loop:

for(int i=0;i<128;i++){
bw.write((char)i);
}
 

Posts:19,725
Registered: 9/26/01
Re: writing "enter" or carrage return into a txt file  
Aug 3, 2004 8:43 AM (reply 1 of 2)



 
Since you wrote every char from 0 thru 127, and the "Enter" character (13) is in that range, you certainly did write it. However, if you're thinking of looking at that file from a text file viewer, you'd need the actual "line sequence" characters, likely 13 followed by 10. You're writing "binary", not "text", so the file viewer (notepad?) isn't going to like it.
 

Posts:2
Registered: 8/3/04
Re: writing "enter" or carrage return into a txt file  
Aug 3, 2004 9:00 AM (reply 2 of 2)



 
thanks for your help warnerja, I am using notepad. What you said worked. Thank you very much.
 
This topic has 2 replies on 1 page.