Can you explain why the bottom one is preferred? We are studying security vulnerabilities. Noncompliant void readData()
Fantastic news! We've Found the answer you've been seeking!
Question:
Can you explain why the bottom one is preferred? We are studying security vulnerabilities.
Noncompliant
void readData() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("file"))); String data = br.readLine(); }
Compliant
void readData2() { ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024); try(FileChannel rdr = (new FileInputStream ("file")).getChannel()){ while (rdr.read(buffer) > 0) { //Do something buffer.clear(); } }catch (Throwable e) { //Handle error } }
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date: