当前位置: 技术问答>java相关
还是网络传输文件的问题,急!解决后一定给分!
来源: 互联网 发布时间:2015-08-07
本文导语: 前一个问题已经结帖 http://www.csdn.net/expert/topic/943/943109.xml?temp=.5929682 我用了 heifei() 的做法,代码如下: // 客户端上传文件 private boolean fileToSocket(String pFileName, Socket pSocket) throws IOException { boolea...
前一个问题已经结帖
http://www.csdn.net/expert/topic/943/943109.xml?temp=.5929682
我用了 heifei() 的做法,代码如下:
// 客户端上传文件
private boolean fileToSocket(String pFileName, Socket pSocket) throws IOException
{
boolean result = false;
File fileUpload = new File(pFileName);
FileInputStream finUpload = new FileInputStream(fileUpload);
try
{
byte[] buf = new byte[4096];
byte[] bufData;
OutputStream soutUpload;
soutUpload = pSocket.getOutputStream();
int len;
while (true)
{
try
{
len = finUpload.read(buf);
if(len
http://www.csdn.net/expert/topic/943/943109.xml?temp=.5929682
我用了 heifei() 的做法,代码如下:
// 客户端上传文件
private boolean fileToSocket(String pFileName, Socket pSocket) throws IOException
{
boolean result = false;
File fileUpload = new File(pFileName);
FileInputStream finUpload = new FileInputStream(fileUpload);
try
{
byte[] buf = new byte[4096];
byte[] bufData;
OutputStream soutUpload;
soutUpload = pSocket.getOutputStream();
int len;
while (true)
{
try
{
len = finUpload.read(buf);
if(len