我试图从具有try-catch块,如何在try catch块
我的功能返回一个布尔值但问题是我不能返回任何值之外访问变量。
我知道try-catch块内部的变量不能在外部访问,但仍然是我想要的。
public boolean checkStatus(){
try{
InputStream fstream = MyRegDb.class.getClassLoader().getResourceAsStream("textfile.txt");
// Use DataInputStream to read binary NOT text.
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;
//Read File Line By Line
strLine = br.readLine();
// Print the content on the console
System.out.println (strLine);
ind.close();
if(strLine.equals("1")){
return false;
}else{
return true;
}
}catch(Exception e){}
}
在我的项目中,这对我来说是一个超级严重的问题。 我用Google搜索了一下,并尝试过自己,但没有解决。
我希望现在我会找到一些解决方案。 我知道它有错误,说返回语句丢失但我想程序正是这样工作。
现在原因,我严格到这种
在我的jar文件我要访问的文本文件查找值1或0,如果“1”,则激活其他禁用。
这就是为什么我使用布尔值。