Cache online-file contents in String rather than local file
<p>I am downloading a text-file from example.com/test.txt and I need the contents only during the runtime of my app, they don't need to be saved to a static file.</p>

<p>My code so far:</p>

<pre><code>            InputStream input = new BufferedInputStream(getURL.openStream());
            OutputStream output = new FileOutputStream(tempFile);

            byte data[] = new byte[1024];

            long total = 0;

            while ((count = input.read(data)) != -1) {
                output.write(data, 0, count);
            }

            output.flush();
            output.close();
            input.close();
</code></pre>

<p>How would I go about writing the online-file contents to a String rather than saving the file locally? I have tried appending <code>data</code> to a String in the while-statement, but just get garbled text (as expected, but I don't know what else to do). Convert <code>byte</code> back to String?</p>

<p>Thanks for your help! </p>
