如下代码,http用流上传图片到服务器,为什么只有一个close(),并没有write()啊?

try {
            inputStream = new FileInputStream(file);
            filePath = UploadFileToFastDFSImpl.uploadFileByStream(inputStream, fileName, file.length());
            is = FileUploadAction.class.getResourceAsStream("/fdfs_client.conf");
            Properties properties = new Properties();
            properties.load(is);
            String port = (String)properties.getProperty("http.tracker_server_port");
            String hostname = (String)properties.getProperty("tracker_server").split(":")[0];
            filePath = "http://"+hostname+":"+port+"/"+filePath;
            inputStream.close();
            is.close();
            file.delete();
            result = "{success:true,filePath:'"+filePath+"'}";
            System.out.println("----filePath:"+filePath+"is:"+is+"port:"+port+"hostname:"+hostname+"----");
        } catch (IOException e) {
            System.out.println("上传图片io异常");
            e.printStackTrace();
            result = "{success:false}";
        } finally {
阅读 1.4k
2 个回答

文件输入流,文件为源,为啥还要write

应该在这个函数里面吧
filePath = UploadFileToFastDFSImpl.uploadFileByStream(inputStream, fileName, file.length());
推荐问题