文件发送程序.doc

时间:2015-07-02 07:36:47
【文件属性】:
文件名称:文件发送程序.doc
文件大小:26KB
文件格式:DOC
更新时间:2015-07-02 07:36:47
文件发送 基于TCP文件发送 public void send() { Scanner input = new Scanner(System.in); Socket socket = null; String s = input.nextLine(); System.out.println(s); File file = new File(s); String name = file.getName(); try { socket = new Socket("192.168.1.5",10000); } catch (IOException e) { e.printStackTrace(); } try { BufferedWriter pw = new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())); pw.write(name); System.out.println("文件名已经传送!"); pw.flush(); pw.write('\n'); } catch (IOException e) { e.printStackTrace(); } //传文件名

网友评论