最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
java实现两台服务器实现文件的复制
时间:2014-09-02 编辑:简简单单 来源:一聚教程网
1.服务器端
代码如下 | 复制代码 |
package sterning; import java.io.BufferedInputStream; public class ServerTest { void start() { System.out.println("文件长度:" + (int) fi.length()); // public Socket accept() throws s = ss.accept(); DataInputStream fis = new DataInputStream(new BufferedInputStream(new FileInputStream(filePath))); int bufferSize = 8192; while (true) { if (read == -1) { } catch (Exception e) { public static void main(String arg[]) { 2.socket的Util辅助类 package sterning; import java.net.*; public class ClientSocket { private int port; private Socket socket = null; DataOutputStream out = null; DataInputStream getMessageStream = null; public ClientSocket(String ip, int port) { /** *//** public void sendMessage(String sendMessage) throws Exception { public DataInputStream getMessageStream() throws Exception { public void shutDownConnection() { } |
3.客户端
代码如下 | 复制代码 |
package sterning; import java.io.BufferedOutputStream; public class ClientTest { private String ip = "localhost";// 设置成服务器IP private int port = 8821; private String sendMessage = "Windwos"; public ClientTest() { } catch (Exception ex) { private boolean createConnection() { } private void sendMessage() { private void getMessage() { try { fileOut.close(); public static void main(String arg[]) { |
相关文章
- Flex A10如何复制粘贴文件?Flex A10复制粘贴文件 11-08
- fso实现整个文件夹内容的复制到另一个文件夹中 04-14
- SpringBoot测试配置属性与web启动环境解析 10-24
- vue中将el-switch值true、false改为number类型的1和0解析 10-24
- Vue中的路由配置项meta使用解读 10-24
- SpringBoot自定义bean绑定解析 10-24