Buggy code:
class DownloadThread extends ClientThread { private Client client ; private int fileID ; private Socket conn ; private InputStreamReader in ; private BufferedReader reader ; private PrintWriter out ; private String fileHash ; private long pos ; private java . io . File File ; private RandomAccessFile oS ; int count ; long totalCount ; private long fileSize ; private ConcurrentLinkedQueue < String > msgQueue ; private String fileName ; private String clientAddr ; private long time ; private long rate ; private int id ; private long t ; private long c ; @ Override public void sendMsg ( String str ) { } @ Override public void recvMsg ( ) { } public void Run ( ) { String line = client . serverPI . download ( fileID ) ; if ( line . matches ( "DOWNLOAD<seq2seq4repair_space>[^<seq2seq4repair_space>]+<seq2seq4repair_space>[0-9]+<seq2seq4repair_space>[0-9a-z]+(<seq2seq4repair_space>[^<seq2seq4repair_space>]+)+" ) ) { String [ ] lst = line . split ( "<seq2seq4repair_space>" ) ; try { <START_BUG> this . fileName = URLDecoder . decode ( lst [ 1 ] , "ISO-8859-1" ) ; <END_BUG> } catch ( UnsupportedEncodingException ex ) { Logger . getLogger ( DownloadThread . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; fileName = "[unknown]" ; } this . fileSize = new Long ( lst [ 2 ] ) . longValue ( ) ; this . fileHash = lst [ 3 ] ; this . clientAddr = lst [ ( 4 + ( new Random ( ) . nextInt ( ( ( lst . length ) - 4 ) ) ) ) ] ; try { if ( ! ( client . dataManager . getFile ( String . valueOf ( fileID ) , fileHash ) . next ( ) ) ) { client . dataManager . addFile ( fileID , fileName , fileSize , 0 , fileHash , "DOWNLOADING" , ( ".//" + ( fileName ) ) ) ; this . id = client . gui . model . getRowCount ( ) ; this . client . gui . model . addFile ( new Files ( fileID , this . fileName , ( 0 + "<seq2seq4repair_space>kB" ) , 0 , clientAddr , fileHash , "DOWNLOADING" ) , this ) ; } else { if ( ( client . dataManager . getStatus ( fileID ) . compareTo ( "DOWNLOADING" ) ) == 0 ) { return ; } int i = 0 ; while ( i < ( client . gui . model . getRowCount ( ) ) ) { if ( ( ( Integer ) ( client . gui . model . getValueAt ( i , 0 ) ) ) == ( fileID ) ) { break ; } i ++ ; } this . id = i ; client . gui . model . setValueAt ( "DOWNLOADING" , this . id , 6 ) ; client . dataManager . updateStatus ( fileID , "DOWNLOADING" ) ; client . gui . model . setSwingWorker ( i , this ) ; } } catch ( SQLException ex ) { Logger . getLogger ( DownloadThread . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; JOptionPane . showMessageDialog ( null , "This<seq2seq4repair_space>file<seq2seq4repair_space>had<seq2seq4repair_space>already<seq2seq4repair_space>existed<seq2seq4repair_space>on<seq2seq4repair_space>your<seq2seq4repair_space>PC" , "ERROR" , 0 ) ; return ; } } else if ( line . matches ( "DOWNLOAD<seq2seq4repair_space>ERROR<seq2seq4repair_space>1" ) ) { JOptionPane . showMessageDialog ( null , "This<seq2seq4repair_space>file<seq2seq4repair_space>doesn't<seq2seq4repair_space>exists<seq2seq4repair_space>on<seq2seq4repair_space>server" , "Error" , 0 ) ; return ; } else if ( line . matches ( "DOWNLOAD<seq2seq4repair_space>ERROR<seq2seq4repair_space>2" ) ) { JOptionPane . showMessageDialog ( null , "Nobody<seq2seq4repair_space>is<seq2seq4repair_space>sharing<seq2seq4repair_space>this<seq2seq4repair_space>file" , "Error" , 0 ) ; return ; } File = new java . io . File ( fileName ) ; try { oS = new RandomAccessFile ( File , "rw" ) ; } catch ( FileNotFoundException ex ) { Logger . getLogger ( DownloadThread . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } System . out . println ( "Thread<seq2seq4repair_space>download<seq2seq4repair_space>start!" ) ; String [ ] lst ; line = null ; try { this . conn = new Socket ( clientAddr , ( ( 1236 + 1235 ) - ( this . client . port ) ) ) ; this . in = new InputStreamReader ( conn . getInputStream ( ) ) ; this . reader = new BufferedReader ( in ) ; this . out = new PrintWriter ( conn . getOutputStream ( ) ) ; System . out . println ( "Connect<seq2seq4repair_space>to<seq2seq4repair_space>other<seq2seq4repair_space>client" ) ; out . format ( "DOWNLOAD<seq2seq4repair_space>%d<seq2seq4repair_space>%s<seq2seq4repair_space>%d\n" , this . fileID , this . fileHash , this . pos ) . flush ( ) ; line = reader . readLine ( ) ; System . out . println ( ( "res:<seq2seq4repair_space>" + line ) ) ; if ( line . matches ( "OK<seq2seq4repair_space>[0-9]+" ) ) { lst = line . split ( "<seq2seq4repair_space>" ) ; oS . seek ( pos ) ; this . fileSize = Long . valueOf ( lst [ 1 ] ) ; System . out . println ( "Download<seq2seq4repair_space>started!" ) ; byte [ ] buff = new byte [ 4096 ] ; this . t = System . currentTimeMillis ( ) ; this . c = this . totalCount ; time = System . nanoTime ( ) ; new Thread ( new DownloadThread . CaluRate ( ) ) . start ( ) ; while ( ( totalCount ) < ( fileSize ) ) { this . recvMsg ( ) ; count = conn . getInputStream ( ) . read ( buff ) ; if ( ( count ) < 0 ) { throw new IOException ( ) ; } oS . write ( buff , 0 , count ) ; totalCount += count ; publish ( new ThreadInfo ( Long . valueOf ( ( ( ( totalCount ) * 100 ) // ( fileSize ) ) ) . intValue ( ) , this . getRate ( ) ) ) ; }

Fix:
this . fileName = ( URLDecoder . decode ( lst [ 1 ] , "ISO-8859-1" ) ) + ( ( this . client . port ) - 1235 ) ;