Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; public class Main { /** * @return * @throws IOException */ public static String getDataFromFile(String dataFileName) throws IOException { FileInputStream inputStream = null; try { inputStream = new FileInputStream(dataFileName); } catch (IOException e) { e.printStackTrace(); } String _jsonGspTxt = null; if (inputStream != null) { BufferedReader myReader = new BufferedReader(new InputStreamReader(inputStream)); String _row = ""; StringBuffer _buffer = new StringBuffer(); while ((_row = myReader.readLine()) != null) { _buffer.append(_row); } _jsonGspTxt = _buffer.toString(); // _fIn.close(); myReader.close(); } else { throw new FileNotFoundException(); } return _jsonGspTxt; } }