【问题标题】:Android-Send/Receive byte[] via TCP Socket [closed]Android-通过 TCP 套接字发送/接收字节 [] [关闭]
【发布时间】:2011-12-14 22:09:21
【问题描述】:

我想通过 TCP 套接字连接发送/接收 byte[] 中的 sqlite 数据库文件 (*.db)?

【问题讨论】:

  • 是的,我想你会喜欢的...这是一个反问句吗?
  • 请不要忽略 previous question 上的 cmets。投票关闭。再次。

标签: java android


【解决方案1】:

这里是:

Socket socket = new Socket(host, port);
FileInputStream fis = new FileInputStream(yourFile);
OutputStream out = socket.getOutputStream();
byte[] buffer = new byte[9182];
int nBytesRead = 0;
while ((nBytesRead = fis.read(buffer) != -1)
{
    out.write(buffer, 0, nBytesRead);
}
out.flush();
out.close();
fis.close();

【讨论】:

  • Google 也知道这一点:Try to google "java socket file transfer"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-13
  • 1970-01-01
  • 1970-01-01
  • 2014-07-13
相关资源
最近更新 更多