try { InputStream in = closer.register(openStream()); return ByteStreams.exhaust(in); } catch (Throwable e) { throw closer.rethrow(e);
public void testExhaust() throws IOException { InputStream in = newTestStream(100); assertEquals(100, ByteStreams.exhaust(in)); assertEquals(-1, in.read()); assertEquals(0, ByteStreams.exhaust(in)); InputStream empty = newTestStream(0); assertEquals(0, ByteStreams.exhaust(empty)); assertEquals(-1, empty.read()); }
try { InputStream in = closer.register(openStream()); return ByteStreams.exhaust(in); } catch (Throwable e) { throw closer.rethrow(e);
try { InputStream in = closer.register(openStream()); return ByteStreams.exhaust(in); } catch (Throwable e) { throw closer.rethrow(e);
@Override public void run() { try { // TODO report checker framework issue that occurs without checkNotNull Socket socket = checkNotNull(heartbeatListenerSocket).accept(); InputStream socketIn = socket.getInputStream(); ByteStreams.exhaust(socketIn); } catch (IOException e) { logger.error(e.getMessage(), e); } } });
@Override public Path persist(TransmissionIdentifier transmissionIdentifier, Header header, InputStream inputStream) throws IOException { ByteStreams.exhaust(inputStream); return null; }
@Override public Path persist(TransmissionIdentifier transmissionIdentifier, Header header, InputStream inputStream) throws IOException { ByteStreams.exhaust(inputStream); return null; }
public static String toMD5(String input, Charset charset, MessageDigest md) { try (InputStream baos = new DigestInputStream(new ByteArrayInputStream(input.getBytes(charset)), md)) { ByteStreams.exhaust(baos); } catch (IOException e) { throw new RuntimeException(e); } byte[] digest = md.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < digest.length; i++) { String hex = Integer.toHexString(HEX_FILTER & digest[i]); if (hex.length() == 1) { // could use a for loop, but we're only dealing with a // single byte hexString.append('0'); } hexString.append(hex); } return hexString.toString(); }
public static String toMD5(String input, Charset charset, MessageDigest md) { try (InputStream baos = new DigestInputStream(new ByteArrayInputStream(input.getBytes(charset)), md)) { ByteStreams.exhaust(baos); } catch (IOException e) { throw new RuntimeException(e); } byte[] digest = md.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < digest.length; i++) { String hex = Integer.toHexString(HEX_FILTER & digest[i]); if (hex.length() == 1) { // could use a for loop, but we're only dealing with a // single byte hexString.append('0'); } hexString.append(hex); } return hexString.toString(); } }
@SuppressWarnings("SameParameterValue") static boolean isReadable(@Nullable ByteSource byteSource, long testLength) { if (byteSource != null) { try { try (InputStream in = byteSource.slice(0, testLength).openStream()) { ByteStreams.exhaust(in); } return true; } catch (IOException e) { log.debug("byte source not readable due to {}", e.toString()); } } return false; }
ByteStreams.exhaust(inputStream);
try { InputStream in = closer.register(openStream()); return ByteStreams.exhaust(in); } catch (Throwable e) { throw closer.rethrow(e);
try { InputStream in = closer.register(openStream()); return ByteStreams.exhaust(in); } catch (Throwable e) { throw closer.rethrow(e);
public void testExhaust() throws IOException { InputStream in = newTestStream(100); assertEquals(100, ByteStreams.exhaust(in)); assertEquals(-1, in.read()); assertEquals(0, ByteStreams.exhaust(in)); InputStream empty = newTestStream(0); assertEquals(0, ByteStreams.exhaust(empty)); assertEquals(-1, empty.read()); }
@Override protected Void execute() throws FirebaseInstanceIdException { String url = String.format( "%s/project/%s/instanceId/%s", IID_SERVICE_URL, projectId, instanceId); HttpResponse response = null; try { HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(url)); request.setParser(new JsonObjectParser(jsonFactory)); request.setResponseInterceptor(interceptor); response = request.execute(); ByteStreams.exhaust(response.getContent()); } catch (Exception e) { handleError(instanceId, e); } finally { disconnectQuietly(response); } return null; } };