如何修复“ java.lang.NumberFormatException:对于输入字符串:”

时间:2019-04-24 16:36:53

标签: java parsing

我正在尝试在Java程序中解析csv数据,以创建一个可以计算扇出比率和BFR的程序。但是,当我尝试将csv文件解析为程序时,它总是显示NumberFormaException。

错误表明这里有问题。

int choice = input.nextInt();

if (choice == 1) {
    bfr1(coba1, coba2);
} else if (choice == 2) {
    bfr1(coba1, coba2);
} else {
    System.out.println("Not available!!!!");
}

并在int pointer1 = Integer,parseInt(pointer)的第97行显示错误

public static void bfr1(String s, List<String> l) {
    //split untuk pointer dan block size
    String[] splitSpasi = s.split(",");
    String pointer = splitSpasi[0].substring(0);
    int pointer1 = Integer.parseInt(pointer);

    //block size
    String blockS = splitSpasi[1].substring(1);
    int blockSn = Integer.parseInt(blockS);

    // Member
    String Member = l.get(0);
    String[] Membersp = Member.split("%");
    String[] MemberAngka = Membersp[1].split(",");
    String ukuranRecord_Member = MemberAngka[0].substring(1);
    int ukuranRecord_MemberIn = Integer.parseInt(ukuranRecord_Member);
    int bfrMember = blockSn/ukuranRecord_MemberIn;

    String keyP = MemberAngka[2].substring(1);
    int keyPin = Integer.parseInt(keyP);
    int hasilFanMember = blockSn/(pointer1+keyPin);

    System.out.println("BFR Member: " + bfrMember);
    System.out.println("Fanout Ratio Member: " + hasilFanMember);
}

我希望输出将计算BFR和扇出比

0 个答案:

没有答案