java - BufferedReader not closed warning not dissapearing -


i using bufferedreader, , though call close() method, eclipse still gives me warning. eclipse not give me warning if place close() call before while, in code not work. there either error in code, or else problem? code:

    hashtable<string, hashtable<string, integer>> buildingstats = new hashtable<string, hashtable<string, integer>>();     try      {         bufferedreader br = new bufferedreader(new filereader(new file("assets/setup/buildings.txt"))); // sets buildings values values in buildings.tx         string line;         int linenum = 0;         while((line = br.readline()) != null)         {             ++linenum;             string[] values = line.split(",");             if (values.length != 3)                 throw new exception("invalid data in assets/setup/buildings.txt @ line " + linenum);             if (buildingstats.containskey(values[0]))             {                 buildingstats.get(values[0]).put(values[1], integer.parseint(values[2]));             }             else              {                 buildingstats.put(values[0], new hashtable<string, integer>());                 buildingstats.get(values[0]).put(values[1], integer.parseint(values[2]));              }          }         br.close();     }      catch (ioexception e)      {         e.printstacktrace();     }      catch (exception e)      {         e.printstacktrace();     }     return buildingstats; 

you should put in method so:

bufferedreader br = null; try {     br = new bufferedreader(new filereader(new file("assets/setup/buildings.txt")));     // things } catch (exception e){    //handle exception } {     try {         br.close();     } catch (exception e){} } 

if still warning try cleaning , rebuilding eclipse project.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -