fileimpl.java
来自「JAVA开发的采用RMI远程机制」· Java 代码 · 共 64 行
JAVA
64 行
package ftp;
import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
public class fileImpl extends UnicastRemoteObject implements fileinterface
{
String currdir = null;
public fileImpl() throws RemoteException
{
super();
currdir=".";
}
public void setDir(String dir)
{
this.currdir = dir;
}
public String getDir()
{
return this.currdir;
}
public String[] getCurrFileNames()
{
File ff = new File(this.getDir());
return ff.list();
}
public File downLoad(String filename)
{
File file = new File(this.getDir()+"\\"+filename);
return file; // the downloade file
}
public void upLoad(String filename,byte[] bb)
{
try{
File ff = new File("e:\\uploade\\"+filename);
// recivere Uploaded the file to Store there
if(!ff.exists())
ff.createNewFile();
FileOutputStream fout = new FileOutputStream(ff);
fout.write(bb,0,bb.length); //wirte file from arry bb to e:\\uploade
}
catch(Exception e1)
{
System.out.println(e1);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?