KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to return a boolean value from my function having try-catch block , But the problem is I cant return any value. I know that a variable inside a try-catch block can't be accessed outside it, but still I want to access it somehow. 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){} } I know that it has error saying return statement missing but I want program exactly working like this. Now the reason I'm strict to this In my jar file I have to access text files for finding values 1 or 0 if "1" then activate else deactivate. that is why I am using Boolean.
Tags (comma-separated)
Save Edits
Cancel