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
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Microeconomics An Intuitive Approach with Calculus
Authors: Thomas Nechyba
1st edition
538453257, 978-0538453257
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App