@Override public void close() { IoUtils.closeQuietly(is); IoUtils.closeQuietly(controlSocket); }
public void destroy() { // If the process hasn't already exited, send it SIGKILL. synchronized (exitValueMutex) { if (exitValue == null) { try { Libcore.os.kill(pid, SIGKILL); } catch (ErrnoException e) { System.logI("Failed to destroy process " + pid, e); } } } // Close any open streams. IoUtils.closeQuietly(inputStream); IoUtils.closeQuietly(errorStream); IoUtils.closeQuietly(outputStream); }
out = new BufferedWriter(new OutputStreamWriter(fout, csn)); } catch (RuntimeException e) { IoUtils.closeQuietly(fout); throw e; } catch (UnsupportedEncodingException e) { IoUtils.closeQuietly(fout); throw e;
/** * Creates a {@code Scanner} with the specified {@code File} as input. The specified charset * is applied when reading the file. * * @param src * the file to be scanned. * @param charsetName * the name of the encoding type of the file. * @throws FileNotFoundException * if the specified file does not exist. * @throws IllegalArgumentException * if the specified coding does not exist. */ public Scanner(File src, String charsetName) throws FileNotFoundException { if (src == null) { throw new NullPointerException("src == null"); } FileInputStream fis = new FileInputStream(src); if (charsetName == null) { throw new IllegalArgumentException("charsetName == null"); } try { setInput(new InputStreamReader(fis, charsetName)); } catch (UnsupportedEncodingException e) { IoUtils.closeQuietly(fis); throw new IllegalArgumentException(e.getMessage()); } }
} catch (SAXException ignored) { } finally { IoUtils.closeQuietly(reader);
sb.append(sw.toString()); } finally { IoUtils.closeQuietly(pw);
IoUtils.closeQuietly(out);
IoUtils.closeQuietly(input);
IoUtils.closeQuietly(in); IoUtils.closeQuietly(is);
IoUtils.closeQuietly(fileStream); continue;
IoUtils.closeQuietly(rd);
public FileReader readFully() throws IOException { int read; int capacity = bytes.length; try { while ((read = Libcore.os.read(fd, bytes, count, capacity - count)) != 0) { count += read; if (count == capacity) { if (unknownLength) { // If we don't know the length of this file, we need to continue // reading until we reach EOF. Double the capacity in preparation. final int newCapacity = capacity * 2; byte[] newBytes = new byte[newCapacity]; System.arraycopy(bytes, 0, newBytes, 0, capacity); bytes = newBytes; capacity = newCapacity; } else { // We know the length of this file and we've read the right number // of bytes from it, return. break; } } } return this; } catch (ErrnoException e) { throw e.rethrowAsIOException(); } finally { closeQuietly(fd); } }
IoUtils.closeQuietly(rd);
IoUtils.closeQuietly(rd);
parse(reader, input.getPublicId(), input.getSystemId()); } finally { IoUtils.closeQuietly(reader); parse(in, encoding, input.getPublicId(), input.getSystemId()); } finally { IoUtils.closeQuietly(in); parse(in, encoding, input.getPublicId(), systemId); } finally { IoUtils.closeQuietly(in);
} catch (IOException ignored) { } finally { IoUtils.closeQuietly(stream);
entityParser.append("</externalEntity>"); } finally { IoUtils.closeQuietly(reader); .getBytes(entityParser.encoding)); } finally { IoUtils.closeQuietly(in); .getBytes(entityParser.encoding)); } finally { IoUtils.closeQuietly(in);
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }
ks.load(fis, passwd); } finally { IoUtils.closeQuietly(fis);
IoUtils.closeQuietly(parser);