• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

First character of a File Becomes "?" on reading

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am reading a file which is stroed in UTF-8 Format and m reading it by code below.
if (is != null) {
InputStreamReader sr = new InputStreamReader(is, "UTF-8");
BufferedReader br = new BufferedReader(sr);
String str = "";
while ((str = br.readLine()) != null) {
writer.append(str + "\r\n");
}}

---- The output is
?
$C_FamilyName $C_FirstName?
$C_ProspectNo


When i am reading this file and printing it to console the first line gets printed as ? but the first line of the file is empty.
Please provide solution on how to resolve this issue.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was the file saved with the BOM ?
 
echarish Kumar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure, if its stored with BOM.. is their a way that i can check that... and also how will it affect the file...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That "?" tells me that it's there Using an binary editor, you can check it. As a workaround, check this.
 
echarish Kumar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe Thanks for your help... the issue i am able to resolve.. thanks a lot..
 
reply
    Bookmark Topic Watch Topic
  • New Topic