用于读取swf的函数,我也将其用于图像,但图像加载正常:
public static InputStream readImage(String file) throws IOException {
InputStream input = new FileInputStream(file);
return input;
}这里是输出的最后一个函数,我在这里传递输入流:
public static void writeImage(InputStream input) {
try
{
byte[] buffer = new byte[1024];
byte[] bytesSend;
int bytesRead;
/*
while ((bytesRead = input.read(buffer)) != -1)
{
responseBody.write(buffer, 0, bytesRead);
}
*/
IOUtils.copy(input, responseBody);
responseBody.flush();
responseBody.close();
}
catch(IOException e)
{
System.out.println("bbbb");
e.printStackTrace(System.out);
}
}我尝试同时使用IOUtils.copy和while loop,得到以下错误:
sun.net.httpserver.StreamClosedException
java.nio.channels.AsynchronousCloseExceptionSWF文件也有加载的模块,因此有4-5个swf请求。
我使用的是哪种服务器实现?
public void run() {
try
{
InetSocketAddress addr = new InetSocketAddress(8080);
HttpServer server = HttpServer.create(addr, 0);
server.createContext("/", new MyHandler());
server.setExecutor(Executors.newCachedThreadPool());
server.start();
System.out.println("Server is listening on port 8080" );
}
catch(IOException e)
{
System.out.println("Http point error");
System.out.println(e);
}
}也许有人对此有一些想法,如果需要的话,我可以提供更多的信息
发布于 2013-12-18 23:00:20
浏览器似乎决定中途停止读取图像文件。
一种可能是您没有在响应中设置正确的内容类型。
另一个原因是你已经安排了浏览器端(例如,在HTML或Javascript中)在一个没有意义的上下文中“获取”SWF文档。
https://stackoverflow.com/questions/20660844
复制相似问题