【发布时间】:2020-10-14 15:18:59
【问题描述】:
public void getConformFileDate(int year,int month,int date,int numOfday,int sr,int dr,int tr,int fr,int kr,int qr){
String PIN = "" ; String check_in = ""; String NDates =""; String Rmonth = "" ; String Ryear = "" ;String people = "" ; String price = "" ;
String single = "" ; String doub = ""; String triple =""; String fam = "" ; String king = "" ;String queen = "" ;
try{
x = new Scanner(new File(conf));
x.useDelimiter("[,\n]");
while(x.hasNext()){
PIN = x.next();
check_in = x.next();
NDates = x.next();
Rmonth = x.next();
Ryear = x.next();
people = x.next();
price = x.next();
single = x.next();
doub = x.next();
triple = x.next();
fam = x.next();
king = x.next();
queen = x.next();
checkWithConformFile(Ryear,Rmonth,check_in,NDates,year,month,date,numOfday,single,doub,triple,fam,king,queen,sr,dr,tr,fr,kr,qr);
//sumcroom = sumcroom + croom;
}
x.close();
}
catch(Exception e){
System.out.println(e);
}
}
在我将一些字符串值(如 Rmonth、Ryear)转换为 int 类型并与我的输入值进行比较之后。 如果我的输入值不在我的文本文件中,它会给出真正的输出。但是我的输入值在我的文本文件中,它给出了错误。
错误: "ava.lang.NumberFormatException: 对于输入字符串:"3
我的文本文件:
000001,2,7,9,2020,1,8000,1,0,0,0,0,0 000002,1,5,9,2020,2,12000,1,1,0,0,0,0 000003,9,12,10,2020,5,26000,1,0,0,1,0,0enter image description here
【问题讨论】:
标签: java