1.9.30 sync.
[gae.git] / java / src / main / com / google / appengine / api / socket / AppEngineSocketInputStream.java
blob834596f4187238441ea9aa2ab62f70e6800627a1
1 // Copyright 2012 Google Inc. All Rights Reserved.
3 package com.google.appengine.api.socket;
5 import java.io.IOException;
6 import java.io.InputStream;
8 /**
9 */
10 class AppEngineSocketInputStream extends InputStream {
11 final AppEngineSocketImpl socketImpl;
13 AppEngineSocketInputStream(AppEngineSocketImpl socketImpl) {
14 this.socketImpl = socketImpl;
17 /**
18 * @see java.io.InputStream#read()
20 @Override
21 public int read() throws IOException {
22 byte[] buff = new byte[1];
23 int count = read(buff, 0, 1);
24 if (count <= 0) {
25 return -1;
27 return buff[0] & 0xff;
30 /**
31 * @see java.io.InputStream#read(byte[], int, int)
33 @Override
34 public int read(byte[] b, int off, int len) throws IOException {
35 return socketImpl.receive(b, off, len);
38 /**
39 * @see java.io.InputStream#available()
41 @Override
42 public int available() throws IOException {
43 return socketImpl.available();