filetargetimpl.java

来自「基于Java技术实现的minipacs系统,可以进行诊断信息登记, 嵌入控件查看」· Java 代码 · 共 62 行

JAVA
62
字号
/* * FileTargetImpl.java * * Created on 8. november 2005, 12:08 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package backup.client;import java.rmi.*;import java.rmi.server.UnicastRemoteObject;import java.io.*;/** * * @author Thomas */public class FileTargetImpl extends UnicastRemoteObject implements FileTarget {    long bytesTransferred = 0;    File file;    FileOutputStream out;                /**     * Creates a new instance of FileTargetImpl      */    public FileTargetImpl(File file) throws RemoteException, IOException {        this.file = file;        out = new FileOutputStream(file);    }    public int write(byte[] bytes) throws RemoteException {        try {            if (out != null) {                out.write(bytes);                bytesTransferred += bytes.length;                return bytes.length;            }            else {                out.flush();                return -1;            }        } catch (Exception e) {            e.printStackTrace();            return -1;        }    }        public long getFileSize() {        return bytesTransferred;    }        public void fireFileTransfered() throws RemoteException {                    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?