public class Solution {
public static void main(String[] args) {
// write your code here
InputStream fileinputstream =null;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String filePath = reader.readLine();
if(filePath!=null && !filePath.equals(""))
{
fileinputstream = new FileInputStream(filePath);
while (fileinputstream.available() > 0) {
int data = fileinputstream.read();
char c = (char) data;
System.out.print(c);
}
fileinputstream.close();
}
reader.close();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
finally
{
try {
if (fileinputstream != null) {
fileinputstream.close();
}
reader.close();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
}
}
}
package com.codegym.task.task13.task1318;
import java.io.*;
/*
Reading a file
*/
public class Solution {
public static void main(String[] args) {
// write your code here
InputStream fileinputstream =null;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String filePath = reader.readLine();
if(filePath!=null && !filePath.equals(""))
{
fileinputstream = new FileInputStream(filePath);
while (fileinputstream.available() > 0) {
int data = fileinputstream.read();
char c = (char) data;
System.out.print(c);
}
}
fileinputstream.close();
reader.close();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
finally
{
try {
if (fileinputstream != null) {
fileinputstream.close();
}
reader.close();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
}
}
}