I need to write a font file of format .ttf to response.I tried to use response.getoutputstream()
and while calling the url.....it received a file of same size and content as far as i see.But it is not working as a font file.here is the code i used....i would really appreciate your help.
File file = new File(SubsettedSavedPath);
if (file.exists()) {
response.addHeader("19.file", "exist");
// out.println("file exist<br><br><br><br><br><br>");
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("19.line.separator");
response.addHeader("20.reading File", "Started");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
String str = stringBuilder.toString();
response.setContentType("font/ttf");
OutputStream out = response.getOutputStream();
out.write(str.getBytes());
// out.write(str.getBytes());
// out.flush();
response.addHeader("21.byte returned", "successful");
out.close();
}