• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scanner Resource leak  RSS feed

 
M Mangion
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using the Scanner to read some values, and my IDE (Eclipse) shows the following warning next to this line:



Resource leak: "input" is never closed.

Any ideas what I am doing wrong, and how can I address this problem?

Thank you very much in advance.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally, the solution to this would be to add

someplace in your code after you are done using it. Actually, the typical paradigm would be to do something like:


But in your situation, you don't want to do that because your wrapped input stream is System.in, which you don't want to close (the VM will take care of that when it shuts down). So you should ignore this warning for this particular case.
 
M Mangion
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your feedback.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!