How to read a file in java?

3.80K viewsJava
0

How to read a file in java – by using FileInputStream

Manohar Changed status to publish July 7, 2019
Add a Comment
0

Use below snippet and try .

 

public  String readFile(String fileWithPath) throws IOException{
		FileInputStream inputStream = new FileInputStream(fileWithPath);
		String readTotalFile = null;
		    try {
		    	readTotalFile = IOUtils.toString(inputStream);
			} 
		 finally {
		    inputStream.close();
		}
		    return readTotalFile;
	}

 

Manohar Changed status to publish July 7, 2019
Add a Comment
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.