fileclient.java

来自「rmi中间件的实例 里面的东西是经过验证的 十分实用」· Java 代码 · 共 73 行

JAVA
73
字号
import java.io.*; 


import java.rmi.*; 



public class FileClient{ 


public static void main(String argv[]) { 


if(argv.length != 2) { 


System.out.println("Usage: java FileClient fileName machineName"); 


System.exit(0); 


} 


try { 


String name = "//" + argv[1] + "/FileServer"; 


FileInterface fi = (FileInterface) Naming.lookup(name); 


byte[] filedata = fi.downloadFile(argv[0]); 


File file = new File(argv[0]); 


BufferedOutputStream output = new 


BufferedOutputStream(new FileOutputStream(file.getName())); 


output.write(filedata,0,filedata.length); 


output.flush(); 


output.close(); 


} catch(Exception e) { 


System.err.println("FileServer exception: "+ e.getMessage()); 


e.printStackTrace(); 


} 


} 


} 

⌨️ 快捷键说明

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