Android File To String

Here’s an example of turning a file into a string, by reading it line by line

File file = new File(path);
InputStream inputStream = new FileInputStream(file);
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder total = new StringBuilder(); 
String line; 

while ((line = r.readLine()) != null) {

Now “total” will contain the file in a StringBuilder.