I'm looking for some security vulnerabilities in this simple Java program that will read a .txt file
Fantastic news! We've Found the answer you've been seeking!
Question:
I'm looking for some security vulnerabilities in this simple Java program that will read a .txt file named EmailAddresses.txt, read each line, and print them back to the console.
the code:
/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license */ package com.mycompany.sdev425_1_carnahan_joshua; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; /** * * @author jim */ public class SDEV425_1_Carnahan_Joshua { /** * @param args the command line arguments */ public static void main(String[] args) { // Read the filename from the command line argument String filename = args[0]; BufferedReader inputStream = null; String fileLine; try { inputStream = new BufferedReader(new FileReader(filename)); System.out.println("Email Addresses:"); // Read one Line using BufferedReader while ((fileLine = inputStream.readLine()) != null) { System.out.println(fileLine); } } catch (IOException io) { System.out.println("File IO exception" + io.getMessage()); } finally { // Need another catch for closing // the streams try { if (inputStream != null) { inputStream.close(); } } catch (IOException io) { System.out.println("Issue closing the Files" + io.getMessage()); } } } }
EmailAddresses.txt file contents:
In case the code block compiles terribly in this question:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: