P
polaris venus via JavaKB.com
when i use this code to transfer a file from the server
to the client, it is appended by some text. why?
another question how can i make resumable transfer?
Client:
Server:
to the client, it is appended by some text. why?
another question how can i make resumable transfer?
Client:
Code:
out = new DataOutputStream(s.getOutputStream());
in = new DataInputStream(s.getInputStream());
fos = new FileOutputStream(file);
bos = new DataOutputStream(fos);
byte [] b = new byte [1024];
int len = 1024;
long c=0;
while((c=in.read(b,0,len))!=-1)
{
bos.write(b,0,len);
bos.flush();
}
Server:
Code:
in = new DataInputStream(connection.getInputStream());
out = new DataOutputStream(connection.getOutputStream());
fis = new FileInputStream(file.getAbsolutePath());
dis = new DataInputStream(fis);
byte [] b = new byte [1024];
int len = 1024;
int i;
while((i=dis.read(b,0,len))!=-1)
{
out.write(b,0,len);
out.flush();
}