IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes File I/O questions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "File I/O questions" Watch "File I/O questions" New topic
Author

File I/O questions

Lucas Mac
Greenhorn

Joined: Jun 12, 2004
Posts: 10
The following is some code where i simply try to take keyboard input fromt he console and append it to the end of a file (these are the first steps to a chat program i need to make). However, the problem I'm having at the moment is that when I hit backspace at the console the characters do not actually get deleted in the output and the backspace character is also included as one of the characters...what is the best way to eliminate this problem?



/* the following is an example of a session of above code...how can i get it to not keep track of backspaces?
===================================
hey man
yO^Hoooooooooooo, ^H^H!!! what's up?
nuttin much you?
nuttin..goodbye
==================================
*/

[ June 15, 2004: Message edited by: Lucas ]

[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ June 16, 2004: Message edited by: Dirk Schreckmann ]

yup
Chris Allen
Ranch Hand

Joined: Feb 01, 2003
Posts: 127
Lucas,
I did not receive the same problem that you did (but I am on a Windows XP pc). I would expect to see this on UNIX-based systems where the control characters are clearly printed in the files. Perhaps you can guard against the printing of this character in your for loop as such:


Again, I wasn't able to discern any difference in my files but give it a try anyways and let me know. The '\u0008' is the unicode value for the backspace character commonly printed on some terminal emulators as ^H
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Lucas,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm using Windows XP Professional, and the contents of the text file definitely contained some funny characters where I'd expect a new line to be.

I'm moving this to the I/O and Streams forum, where folks might have some further ideas on nudging you in the right direction...
 
 
subject: File I/O questions
 
Threads others viewed
91%
writing from a jar
I/O
Reading from URL, problems with encoding
Accessing HTTPS site using URL
developer file tools