本帖最后由 张玉建 于 2013-9-26 23:49 编辑
- public class PropertiesDome {
- /**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Properties prop = new Properties();
File file= new File("counnt.ini");
if(!(file.exists()))
{
file.createNewFile();
}
FileInputStream fileIn= new FileInputStream(file);
prop.load(fileIn);
int counnt =0;
String value = prop.getProperty("time");
if(value!=null) {
counnt= Integer.parseInt(value);//也就是这里出现异常
if(counnt>=5)
{
System.out.println("次数已到");
}
}
counnt++;
prop.setProperty("time", counnt+" ");
FileOutputStream fileOut=new FileOutputStream(file);
prop.store(fileOut,"");
fileIn.close();
fileOut.close();
} - }
Exception in thread "main" java.lang.NumberFormatException: For input string: "1 "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:456)
at java.lang.Integer.parseInt(Integer.java:497)
at com.intcast.mianshi.PropertiesDome.main(PropertiesDome.java:37)
- counnt= Integer.parseInt(value);//也就是这里出现异常
- 求解释
|