• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File IO not returning certain characters.

 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try reading with InputStream instead of Reader

E.g. FileInputStream,BufferedInputStream
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry.ya that does not make sense.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have corrected this problem. I was some bad logic elsewhere in the code. Thanks for verifying that this code was working correctly guys!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic