Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > JAVA
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-08-2007
danielfvalverde danielfvalverde is offline
Registrado
 
Registrado: ago 2007
Posts: 1
Poder: 0
danielfvalverde Va por buen camino
problema con flujos

hola!!
necesito ayuda...tengo armado un chat y le estoy agregando una parte donde el usuario puede subir archivos al servidor...
el tema es que el servidor no reconoce donde termina el archivo por lo que le mando un mensaje antes de enviar cada parte del buffer al servidor...pero no lo ve y pasa de largo en el while..(del server)


Cliente

salida = new PrintWriter(socket.getOutputStream(), true);


File file=new File (Archivo);
FileInputStream archivoaenviar = null;
try {
archivoaenviar = new FileInputStream(Archivo);
} catch (FileNotFoundException e1)
{
procesos.errorFatal(e1,"error al buscar el archivo");
}
byte[] buf = new byte[1024];
int len=0;
try {
while ((len = archivoaenviar.read(buf)) > 0)
{
salida.println("paquete2184");
System.out.println("se entro a donde se lee buffer" + buf);
salida.write(buf, 0, len);
}
} catch (IOException e1) {
e1.printStackTrace();
}
archivoaenviar.close();
System.out.println("seenviaarchivo");

SERVER

if (textoUsuario.equals("seenviaarchivo2184"))
{
salida.println("serecibepeticiondeupload2184");
System.out.println("se entro al metodo q recibe el archivo");
//CREO LA INSTANCIA PARA ESCRIBIR EL ARCHIVO EN DISCO
FileOutputStream out = null;
try {
out = new FileOutputStream(new java.io.File("C:\\llego.txt"));
System.out.println("se creo la salida a un archivo");
} catch (FileNotFoundException e) {
errorFatal(e,"error al generar el archivo de recepcion file not found");
}
byte[] buf = new byte[1024];
int len=0;
System.out.println("casi entra al try del while q lee el buffer");
try {
while ( (textoUsuario=entrada.readLine()) == "paquete2184" )
System.out.println("entro al while del paquete");
while((len = entrada.read(buf)) > 0)
System.out.println("se entro a donde se lee buffer" + buf);
out.write(buf, 0, len);
break;
}
}
} catch (IOException e) {
errorFatal(e,"error al leer el buffer del archivo recibido");
}
try {

out.close();
} catch (IOException e) {
errorFatal(e,"error al cerrar flujos o al crearlo");
}
out.close();
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Diagramas de flujos lucasarts_18 Varios 11 04-11-2005 21:18:36


La franja horaria es GMT +2. Ahora son las 08:11:08.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi