1 16 package net.sf.jftp.util; 17 18 import net.sf.jftp.*; 19 import net.sf.jftp.config.*; 20 import net.sf.jftp.gui.framework.*; 21 import net.sf.jftp.net.*; 22 import net.sf.jftp.system.LocalIO; 23 import net.sf.jftp.util.*; 24 25 import java.awt.*; 26 import java.awt.event.*; 27 28 import java.io.*; 29 30 import java.net.*; 31 32 import java.util.*; 33 34 import javax.swing.*; 35 import javax.swing.event.*; 36 37 38 public class JReciever implements Runnable 39 { 40 private DataInputStream in; 41 private Thread reciever; 42 private byte[] buf = new byte[4048]; 43 44 public JReciever(DataInputStream in) 45 { 46 this.in = in; 47 reciever = new Thread (this); 48 reciever.start(); 49 } 50 51 public void run() 52 { 53 try 54 { 55 while(true) 56 { 57 int cnt = in.read(buf); 58 59 if(cnt == -1) 60 { 61 RawConnection.output.append(">>> Connection closed..."); 62 63 LocalIO.pause(100); 64 65 JScrollBar bar = RawConnection.outputPane.getVerticalScrollBar(); 66 bar.setValue(bar.getMaximum()); 67 68 in.close(); 69 70 return; 71 } 72 else 73 { 74 String tmp = new String (buf); 75 tmp = tmp.substring(0, cnt); 76 77 RawConnection.output.append(tmp); 78 LocalIO.pause(100); 79 80 JScrollBar bar = RawConnection.outputPane.getVerticalScrollBar(); 81 bar.setValue(bar.getMaximum()); 82 83 LocalIO.pause(400); 84 } 85 } 86 } 87 catch(Exception ex) 88 { 89 ex.printStackTrace(); 90 } 91 } 92 93 public void reset(DataInputStream in) 94 { 95 reciever.destroy(); 96 this.in = in; 97 reciever = new Thread (this); 98 reciever.start(); 99 } 100 } 101 | Popular Tags |