Back to project page android-qq.
The source code is released under:
Apache License
If you think the Android project android-qq listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.myandroid.util; /*ww w. j a v a 2s . c o m*/ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.net.Socket; public class MediaTcpClient { Msg msg = null; String path = null; public MediaTcpClient(Msg msg, String path) { this.msg = msg; this.path = path; } public void start() { Client c = new Client(); c.start(); } class Client extends Thread { public void run() { try { creatClient(); // Tools.sendProgress=-1; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void creatClient() throws Exception { Socket s = new Socket(msg.getSendUserIp(), 2222); // ????? File file = new File(path); BufferedInputStream is = new BufferedInputStream(new FileInputStream(file)); BufferedOutputStream os =new BufferedOutputStream( s.getOutputStream()); // ????? double n = 1; // long part = file.length() / Tools.byteSize;// ?????? // long surplus = file.length() % Tools.byteSize;// ?????????? byte[] data = new byte[1024*5];// ??????????? int len=-1; while ((len=is.read(data))!= -1) { os.write(data,0,len); //Tools.sendProgress+=len;//???? } //Tools.sendProgress=-1; is.close(); os.flush(); os.close(); //??????????????????? Tools.out("???????"); } }