日期:2014-05-17 浏览次数:20828 次
public boolean sendExcel() {
Socket socket;
ServerSocket ss;
DataOutputStream ps;
byte[] sendBytes = null;
try {
ss = new ServerSocket(this.port);
socket = ss.accept();
ps = new DataOutputStream(socket.getOutputStream());
fileinputstream = new FileInputStream(this.file);
sendBytes = new byte[fileinputstream.available()];
while (true) {
int read = 0;
if (fileinputstream != null) {
read = fileinputstream.read(sendBytes);
}
if (read == -1) {
break;
}
ps.write(sendBytes, 0, read);
}
Thread.sleep(5000);
ps.flush();
System.out.println("文件发送完成");
return true;
} catch (Exception e1) {
e1.printStackTrace();
return false;
}
}
class Program
{
static void Main(string[] args)
{
string host;
int port;
string path;
try
{
//int port = 2000;
//string host = "127.0.0.1";
lable:
Console.Write("设定服务端ip:");
//"127.0.0.1:2000"
// host = Console.ReadLine();
host = "192.168.0.221";
Console.Write("设定服务端port:");
//port = Int32.Parse(Console.ReadLine());