Welcome![Sign In][Sign Up]
Location:
Search - Multi-threaded file transfer java

Search list

[JSP/JavaQQ

Description: 本程序是基于TCP/IP协议的网络通信程序,运用了Java的流、文件、多线程等编程技术。套接字对象在网络编程中扮演着重要的角色,该程序就是一个基于套接字技术编写的简单聊天工具。聊天功能所使用的输入输出流分别是BufferedReader和PrintWriter,服务器为客户端启动一个线程,在该线程中通过套接字和客户交流信息。当向服务器发送一条聊天信息:“Hello”时,服务器要向这个线程中的输出流写入信息:“Hello”,那么客户端套接字的输入流就读取到了这条消息。文件传输分为文件发送和文件接收两部分,当服务器端要向客户端发送文件时,先调用字节输入流FileInputStream从本机读取想要发送的文件,再将信息通过字节输出流BufferedOutputStream发送到客户端,这样客户端的字节输入流BufferedInputStream就读取到了相应信息,客户端再通过字节输出流FileOutputStream将信息以文件形式存入本机。-This program is based on network communication program TCP/IP protocol, the use of Java streams, files, and other multi-threaded programming techniques. Socket object plays an important role in network programming, the program is written in a simple socket-based chat tool technology. Input and output streams chat are used BufferedReader and PrintWriter, the server for the client to start a thread in the thread through the socket and customers to exchange information. When sending a chat message to the server: " Hello" , the server would like this thread output stream to write information: " Hello" , then the client socket input stream is read to this message. File transfer files sent and received document is divided into two parts, when the client would like the server to send the file, byte input stream FileInputStream first call to read the file you want to send from the machine, then the information output by the byte stream BufferedOutputStream sent to the client, s
Platform: | Size: 7168 | Author: 佟文浩 | Hits:

CodeBus www.codebus.net