Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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  }  }   


Step by Step Solution

There are 3 Steps involved in it

Step: 1

In the context of security vulnerabilities the compliant code snippet is preferred over the noncompliant one due to the following reasons Resource Lea... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions

Question

What behaviour demonstrates where they are on this scale?

Answered: 1 week ago