use of com.codename1.io.BufferedInputStream in project CodenameOne by codenameone.
the class AndroidImplementation method openInputStream.
/**
* @inheritDoc
*/
public InputStream openInputStream(Object connection) throws IOException {
if (connection instanceof String) {
String con = (String) connection;
if (con.startsWith("file://")) {
con = con.substring(7);
}
InputStream fc = createFileInputStream(con);
BufferedInputStream o = new BufferedInputStream(fc, con);
return o;
}
if (connection instanceof HttpURLConnection) {
HttpURLConnection ht = (HttpURLConnection) connection;
if (ht.getResponseCode() < 400) {
return new BufferedInputStream(ht.getInputStream());
}
return new BufferedInputStream(ht.getErrorStream());
} else {
return new BufferedInputStream(((URLConnection) connection).getInputStream());
}
}
use of com.codename1.io.BufferedInputStream in project CodenameOne by codenameone.
the class GameCanvasImplementation method openInputStream.
/**
* @inheritDoc
*/
public InputStream openInputStream(Object connection) throws IOException {
if (connection instanceof String) {
FileConnection fc = (FileConnection) Connector.open((String) connection, Connector.READ);
BufferedInputStream o = new BufferedInputStream(fc.openInputStream(), (String) connection);
o.setConnection(fc);
return o;
}
return new BufferedInputStream(((HttpConnection) connection).openInputStream(), ((HttpConnection) connection).getURL());
}
Aggregations