Switching project from JDK 1.7 to 1.6 BufferedReader
java, transfer
Solution
It's not a matter of `BufferedReader` being a problem - it's your try-with-resources statement, which was introduced in Java 7. You'll need to close the reader manually:
BufferedReader reader = new BufferedReader(new FileReader(sDataPath));
try {
...
} finally {
reader.close();
}
As an aside, I'd advise against using `FileReader` - use an `InputStreamReader` wrapping a `FileInputStream` so you can specify the encoding.
Oh, and if you're allowed to use external libraries, you may find that Guava will make your resource handling simpler :)
Problem
I had to switch my school project JDK 1.7 to 1.6. I created a new project on platform 1.6 and copied all packed in my project and seems like 1.6 doesn't support this kind of buffered reader, any help please? I need to read from a file in src. if I use Scanner should I be fine? ``` try (BufferedReader br = new BufferedReader(new FileReader(sDataPath))){ Error " Resource specification not allowed here for source level below 1.7" ```