0

File1 Content:

AddressBlock1|AddressBlock2

Main Rd. 1|Westpunt

EOL is Windows and encoding is UTF8

Java code snippet to read:

Scanner sc = new Scanner(new File(File1),"UTF-8");
while (sc.hasNextLine()) {
    String line=sc.nextLine();
    System.out.println(line);
}

Output:

?AddressBlock1|AddressBlock2
Main Rd. 1|Westpunt

Its appending ? in first line. What could be the reason?

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Varun T
  • 11
  • 2
  • 1
    Probably [BOM](http://stackoverflow.com/questions/17405165/first-character-of-the-reading-from-the-text-file-%C3%AF) – Sotirios Delimanolis May 25 '16 at 17:54
  • You need to make sure that when you read the file, you also use UTF-8 encoding. If not, you'll have this "strange" output yes. – Tunaki May 25 '16 at 17:57

0 Answers0