小编Sar*_*raz的帖子

Java-Scanner 不适用于 nextByte()

Scanner Sc = new Scanner(new File("Input.bin"));
String s = Sc.nextLine();
fsize = Integer.parseInt(s); // Reads 4

s = Sc.nextLine();
int mapSize = Integer.parseInt(s);     // Reads 3 
for (int i = 0; i < mapSize; i++)
{
    byte value = 0;
    value = Sc.nextByte();  // Here it is throwing the exception it should have
                            // print the ascii of 'b' which is 98????

    String key = Sc.nextLine();
    key = key.trim();

    dcMap.put(key, (char)value);
 // System.out.println(key + " " + (char)value);
}
Run Code Online (Sandbox Code Playgroud)

Input.bin …

java

4
推荐指数
1
解决办法
2320
查看次数

标签 统计

java ×1