Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem reading a html file  RSS feed

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am writting an Mail Servlet Application using Java Mail API.
In in the application, i am sending an html/.htm file as an attachment. When i open the attachment from the mail, characters like ' and " appears as question mark(?). My question is, how to read the single quotes and double quotes?

Here is the code snippet:

BufferedReader din;
String s;
din = new BufferedReader(new InputStreamReader(new BufferedInputStream(new FileInputStream(file))));
//while((s = din.readLine())!= null)
StringBuffer sBuff=new StringBuffer();
while ((s = din.readLine()) != null) {
sBuff.append(s + "\n");
}
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably need to set the character encoding on the attachment.

Moving to Other Java APIs...
 
Manjit Barman
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilja Preuss,

Yes, that was the reason. I could figure out that!
Anyway, thanks a heap for your response.
You are great though!

Manjit
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!