I have following code which reads data from text file and prints to browser. But when it gets data like "abc - abc " then in browser it shows junk characters like " ¬タモ"... What could be the problem ? fis points to text file. Read data from text file and write to browser. thnx in advanced.
f = new File(URLDecoder.decode(filePathStr), URLDecoder.decode(fileName));
fis = new FileInputStream(f);
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", "-1");
res.setHeader("Cache-Control", "no-cache");
req.setCharacterEncoding("UTF-8");
res.setContentType("text/html;charset=UTF-8");
out = res.getWriter();
for (int i = fis.read(); i != -1; i = fis.read()) {
if (i == '\n')
out.print("</BR>");
else
out.write((byte) i);
}