Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/04/2011, 08:01
tabu666
 
Fecha de Ingreso: abril-2011
Mensajes: 1
Antigüedad: 13 años, 1 mes
Puntos: 1
Respuesta: duda java secure channel

Perdon por revivir este tema, pero yo tambien tenia esta duda y nunca encontre una buena solucion, asi que ahi esta la mia.

La clave esta en

"System.out.print(new String(tmp,0,i))"

en vez de hacer una impresion por pantalla, podrias guardar el resultado en un String y usarlo en lo que quieras:

Código:
byte[] tmp=new byte[1024];
      while(true){
        while(in.available()>0){
          int i=in.read(tmp, 0, 1024);
          if(i<0)break;
         String alfa = new String(tmp, 0, i);
        }
        if(channel.isClosed()){
          System.out.println("exit-status: "+channel.getExitStatus());
          break;
        }
        try{Thread.sleep(1000);}catch(Exception ee){}
      }

JoptionPane.showMessageDialog(null,alfa);