Java scanner not going through entire file

后端 未结 8 1062
悲&欢浪女
悲&欢浪女 2020-11-30 11:31

I\'m writing a program in Java and one of the things that I need to do is to create a set of every valid location for a shortest path problem. The locations are defined in a

相关标签:
8条回答
  • 2020-11-30 12:05

    I encountered the same problem and this is what I did to fix it:

    1.Saved the file I was reading from into UTF-8
    2.Created new Scanner like below, specifying the encoding type:
    
    
       Scanner scanner = new Scanner(new File("C:/IDSBRIEF/GuidData/"+sFileName),"UTF-8");   
    
    0 讨论(0)
  • 2020-11-30 12:05

    You should use this :

    Scanner scanner = new Scanner(fileObj).useDelimiter("\z");
    System.out.println(scanner.next());

    0 讨论(0)
提交回复
热议问题