To read a file to string in Java you can use the following snippet.
Sample Java
public static string readFileToString(FileInputStream _fileInputStream)
{
try {
DataInputStream dataInputStream = new DataInputStream (_fileInputStream);
byte[] Bytes = new byte[dataInputStream.available ()];
dataInputStream.readFully (Bytes);
dataInputStream.close ();
String result = new String (Bytes, 0, Bytes.length, "Cp850");
return result;
}
catch (Exception e) {
e.printStackTrace();
return "";
}
}
RT @CodeSnippetsNET: How to read a file to string in #Java http://t.co/LI4DxL35YX #programming #code #coding #develop