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"
It’s not a matter of
BufferedReaderbeing a problem – it’s your try-with-resources statement, which was introduced in Java 7. You’ll need to close the reader manually:As an aside, I’d advise against using
FileReader– use anInputStreamReaderwrapping aFileInputStreamso 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 🙂