The Artima Developer Community
Sponsored Link

Java Answers Forum
Sockets & images

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Antonio

Posts: 1
Nickname: tazonin
Registered: Apr, 2004

Sockets & images Posted: Apr 19, 2004 2:00 PM
Reply to this message Reply
Advertisement
Hello!

First of all, sorry of my english, because I am Spanish.
I am developping a Client/Server application using sockets. I must transfer a .jpg file. This is the code I use in the server to receive the file:

byte[] datos = new byte[(int)longitud];
dis.skipBytes(1);//
long i = 0;
while (i<longitud)
{
datos[(int)i] = dis.readByte();
i++;
}
File foto = new File("./Mascarada/fotosServidor/" + codigoSubida + ".jpg");
FileOutputStream fos = new FileOutputStream(foto);
fos.write(datos);
fos.close();//

I think the problem is in this part of code, because I have tested that all the bytes are sent to the server. The server gets blocked always when it reads a byte with the integer value '-39'. It is very strange.

Do you know a better way of sending a file using sockets?

Thank you very much

Topic: converting Previous Topic   Next Topic Topic: Mapping dependent objects in entity beans

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use