wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes File IO not returning certain characters. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File IO not returning certain characters." Watch "File IO not returning certain characters." New topic
Author

File IO not returning certain characters.

Brian M Smith
Ranch Hand

Joined: Aug 13, 2009
Posts: 35
Objective: I'm using JavaMail to send emails to customer. I'm using File IO to read in text files, and potentially html files, from disk.

This is an example of what content is stored in the file.



A few things about this file. After reading the contents out, I'm replacing the <firstname> and <lastname> "tags" with the customers first and last name. The problem is that when I read each line from the file those "tags" are not being read. Here is the code I have for reading the files.



You guys can rest assure that the file and file path are correct as I have debug code not shown that will show that I'm able to read certain parts out of the file.

Any ideas?
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Try reading with InputStream instead of Reader

E.g. FileInputStream,BufferedInputStream


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

@Siva Masilamani: Exactly how would that help?

@Brian M Smith: I don't see anything wrong with your code. As a matter of fact, it works fine for me:



The contents of test.in:



The output:


So the problem is not in the code that you have shown us.
By the way, reusing StringBuffer instances is of questionable benefit.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Sorry.ya that does not make sense.
Brian M Smith
Ranch Hand

Joined: Aug 13, 2009
Posts: 35
I have corrected this problem. I was some bad logic elsewhere in the code. Thanks for verifying that this code was working correctly guys!
 
jQuery in Action, 2nd edition
 
subject: File IO not returning certain characters.