java.security.AccessControlException:
SecurityManagerProxy.java, method checkRead, line: 118
How should we complete file io tasks? getting the above error.
package com.codegym.task.task18.task1801;
import java.io.FileInputStream;
import java.io.*;
/*
Maximum byte
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String filename = reader.readLine();
FileInputStream inputStream = new FileInputStream("/users/jyothi/Downloads/"+filename);
long sum =0;
while (inputStream.available() > 0) //as long as there are unread bytes
{
int data = inputStream.read(); //Read the next byte
sum += data; //Add it to the running total
}
inputStream.close(); // Close the stream
System.out.println(sum); // Display the sum on the screen.
}
}