Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java读取SWF并输出到浏览器SocketCloseException_Java_Actionscript 3_Sockets - Fatal编程技术网

Java读取SWF并输出到浏览器SocketCloseException

Java读取SWF并输出到浏览器SocketCloseException,java,actionscript-3,sockets,Java,Actionscript 3,Sockets,用于读取swf的函数,我也将其用于图像,但图像加载正常: public static InputStream readImage(String file) throws IOException { InputStream input = new FileInputStream(file); return input; } 这里是我传递输入流的最后一个输出函数: public static void writeImage(InputStream input) {

用于读取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循环
,但出现以下错误:

sun.net.httpserver.StreamClosedException

java.nio.channels.AsynchronousCloseException
SWF文件也有加载的模块,因此有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);
    }

}

也许有人对此有一些想法,如果需要的话,我可以提供更多信息

看起来浏览器正在决定中途停止读取图像文件

一种可能是您没有在响应中设置正确的内容类型


另一个原因是,您已将浏览器端(例如,在HTML或Javascript中)安排为在毫无意义的上下文中“获取”SWF文档。

我已将内容类型设置为其应用程序/x-shockwave-flash,您所说的“安排浏览器端”是什么意思?不,它不是关于图像,它是关于SWF,有时它加载成功,但是套接字关闭了,我在一个程序中并行运行http和套接字如果它不是关于图像,为什么要调用方法
readImage
writeImage
??无论哪种方式,我认为这与浏览器端发生的事情有关。浏览器的web开发UI/日志中是否显示了任何内容?是的,显示了应用程序flash,但没有加载所有模块,甚至没有加载任何模块。我使用SWF和图像的readImage和writeImage,它们都工作,SWF加载到浏览器中,但我不明白为什么会出现错误