Fix some caching bugs

This commit is contained in:
Cameron Gutman
2015-01-31 00:13:51 -05:00
parent 72d3576257
commit a490da5e5c
3 changed files with 29 additions and 18 deletions

View File

@@ -38,12 +38,14 @@ public class CacheHelper {
return new FileOutputStream(openPath(true, root, path));
}
public static String readInputStreamToString(InputStream in) {
Scanner s = new Scanner(in);
public static String readInputStreamToString(InputStream in) throws IOException {
Reader r = new InputStreamReader(in);
StringBuilder sb = new StringBuilder();
while (s.hasNext()) {
sb.append(s.next());
char[] buf = new char[256];
int bytesRead;
while ((bytesRead = r.read(buf)) != -1) {
sb.append(buf, 0, bytesRead);
}
return sb.toString();