 <p>Use the following code to convert content of file (text or csv) in String.</p> <pre><code> InputStream in; String str = ""; try { in = new URL(url).openStream(); int size = in.available(); for (int i = 0; i &lt; size; i++) { char ch = (char) in.read(); str = str.concat(ch + ""); } in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } </code></pre>