TCPFileUploadClient
public class TCPFileUploadClient{
? ? public static void main(String[] args) throws IOException {
? ? Socket socket = new Socket(InetAddress.getLocalHost(), 8888);
? ? String filePath = "e:\\qie.png";
? ? BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filePath));
? ? byte[] bytes = StreamUtils.streamToByteArray(bis);
? ? BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
? ? bos.write(bytes);
? ? bis.close();
? ? socket.shutdownoutput();
? ? InputStream inputStream = socket.getInputStream();
? ? String s = StreamUtils.streamToString(inputStream);
? ? System.out.println(s);
? ? inputStream.close();
? ? bos.close();
? ? socket.close
標(biāo)簽: