java rmi上传下载512字节OutputStream

发布时间 2023-07-20 14:57:02作者: lydstory
    /* JADX INFO: Access modifiers changed from: protected */
    public final void downloadFile(Parameter parameter, OutputStream out) throws XException {
        if (!this.session.isEffective()) {
            throw new XException(10000000, "连接会话无效");
        }
        if (out == null) {
            throw new XException("输出流为空");
        }
        if (this.session.isLocal()) {
            return;
        }
        Socket socket = this.session.getSocket();
        if (this.session.getTimeout() > 1000) {
            try {
                socket.setSoTimeout(this.session.getTimeout());
            } catch (SocketException e) {
                throw new XException("连接错误", e.getMessage());
            }
        }
        Transport transport = new Transport(socket, "GET", "/CSSIS/RMIFile");
        try {
            try {
                transport.writeHeader(parameter, 0L);
                transport.flush();
                transport.readHeader();
                byte[] bs = new byte[512];
                for (int n = transport.read(bs); n > 0; n = transport.read(bs)) {
                    out.write(bs, 0, n);
                }
            } catch (IOException e2) {
                throw new XException("发送文件失败", e2.getMessage());
            }
        } finally {
            transport.close();
            closeSocket(socket);
        }
    }
}