public void close() { for (InputStream in : ins) { Util.closeQuietly(in); } } }
private static String inputStreamToString(InputStream in) throws IOException { return Util.readFully(new InputStreamReader(in, Util.UTF_8)); }
/** * Closes the cache and deletes all of its stored values. This will delete * all files in the cache directory including files that weren't created by * the cache. */ public void delete() throws IOException { close(); Util.deleteContents(directory); }
/** * Deletes the contents of {@code dir}. Throws an IOException if any file * could not be deleted, or if {@code dir} is not a readable directory. */ static void deleteContents(File dir) throws IOException { File[] files = dir.listFiles(); if (files == null) { throw new IOException("not a readable directory: " + dir); } for (File file : files) { if (file.isDirectory()) { deleteContents(file); } if (!file.delete()) { throw new IOException("failed to delete file: " + file); } } }
/** Sets the value at {@code index} to {@code value}. */ public void set(int index, String value) throws IOException { Writer writer = null; try { writer = new OutputStreamWriter(newOutputStream(index), Util.UTF_8); writer.write(value); } finally { Util.closeQuietly(writer); } }
Util.closeQuietly(reader);
Util.closeQuietly(ins[i]); } else { break;