0
我試圖在瀏覽器上使用NanoHTTPD server
顯示圖像,但始終沒有顯示。 這是我的發球方法的一部分:NanoHTTPD:顯示圖像
else if(uri.contains(".png")){
SmallBinaryFiles smallBinaryFiles = new SmallBinaryFiles();
InputStream is = new InputStream() {
@Override
public int read() throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
};
long i=0;
try {
//smallBinaryFiles.readSmallBinaryFiles(uri): converts binary file given by uri to byte[]
is = new ByteArrayInputStream(smallBinaryFiles.readSmallBinaryFile(uri));
while ((is.read()) != -1){
i++;
}
} catch (IOException ex) {
Logger.getLogger(HelloServer.class.getName()).log(Level.SEVERE, null, ex);
}
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, MIME_PNG, is,i);
}
//declaration of MIME_PNG in NanoHTTPD Core
public static final String MIME_PNG = "image/png";