本文整理汇总了Java中com.codename1.io.Util.readInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java Util.readInputStream方法的具体用法?Java Util.readInputStream怎么用?Java Util.readInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.io.Util
的用法示例。
在下文中一共展示了Util.readInputStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readResponse
import com.codename1.io.Util; //导入方法依赖的package包/类
protected void readResponse(InputStream input) throws IOException {
byte[] bi = Util.readInputStream(input);
responseText.setText(new String(bi));
input = new ByteArrayInputStream(bi);
if(json) {
JSONParser jp = new JSONParser();
Hashtable h = jp.parse(new InputStreamReader(input));
t.setModel(new JSONTreeModel(h));
} else {
XMLParser xp = new XMLParser();
Element response = xp.parse(new InputStreamReader(input));
t.setModel(new XMLTreeModel(response));
}
}
示例2: toByteArray
import com.codename1.io.Util; //导入方法依赖的package包/类
private byte[] toByteArray(InputStream i) throws IOException {
if(i instanceof BufferedInputStream) {
InputStream inp = ((BufferedInputStream)i).getInternal();
if(inp instanceof NSDataInputStream) {
return ((NSDataInputStream)inp).getArray();
}
}
return Util.readInputStream(i);
}
示例3: play
import com.codename1.io.Util; //导入方法依赖的package包/类
@Override
public void play() {
if(isVideo) {
if(component == null && nativePlayer) {
// Mass source of confusion. If getVideoComponent() has been called, then
// we can't use the native player.
if(uri != null) {
moviePlayerPeer = nativeInstance.createNativeVideoComponent(uri, onCompletionCallbackId);
} else {
try {
long val = getNSData(stream);
if(val > 0) {
moviePlayerPeer = nativeInstance.createNativeVideoComponentNSData(val, onCompletionCallbackId);
Util.cleanup(stream);
} else {
byte[] data = Util.readInputStream(stream);
Util.cleanup(stream);
moviePlayerPeer = nativeInstance.createNativeVideoComponent(data, onCompletionCallbackId);
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
nativeInstance.showNativePlayerController(moviePlayerPeer);
return;
}
if(moviePlayerPeer != 0) {
nativeInstance.startVideoComponent(moviePlayerPeer);
}
} else {
nativeInstance.playAudio(moviePlayerPeer);
}
}
示例4: getBlob
import com.codename1.io.Util; //导入方法依赖的package包/类
public byte[] getBlob(int index) throws IOException {
if(closed) {
throw new IOException("Cursor is closed");
}
try {
Blob b = resultSet.getBlob(index+1);
InputStream is = b.getBinaryStream();
return Util.readInputStream(is);
} catch (SQLException ex) {
ex.printStackTrace();
throw new IOException(ex.getMessage());
}
}
示例5: create
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* Creates an image from the input stream
*
* @param i the input stream
* @return newly created encoded image
* @throws java.io.IOException if thrown by the input stream
*/
public static EncodedImage create(InputStream i) throws IOException {
byte[] buffer = Util.readInputStream(i);
if(buffer.length > 200000) {
System.out.println("Warning: loading large images using EncodedImage.create(InputStream) might lead to memory issues, try using EncodedImage.create(InputStream, int)");
}
return new EncodedImage(new byte[][] {buffer});
}