public void NoiFile() {
        FileInputStream fi = null;
        FileOutputStream fo = null;
        byte[] buffer;
        String tenfile = fInfo.getTenfile().replace(".torrent", "");
        
        LogFile.Write("#BEGIN NoiFile(): " + tenfile);
        
        try {
            fInfo.kiemTraVaTaoThuMuc(ThongTinChunk.duongDanLuuFileGhep + tenfile + "/");
            fo = new FileOutputStream(ThongTinChunk.duongDanLuuFileGhep + tenfile + "/" + tenfile);
            buffer = new byte[(int) fInfo.getKichThuocChunk()];
            LogFile.Write("So chunk: " + fInfo.getSochunk());
            
            // if we have no listeners, do nothing...
            if (listeners != null && !listeners.isEmpty()) {
                // make a copy of the listener list in case
                //   anyone adds/removes listeners
                Vector targets;
                synchronized (this) {
                    targets = (Vector) listeners.clone();
                }
                // create the event object to send
                CustomEventObject event = new CustomEventObject(0, fInfo.getSochunk());
                event._object1 = fInfo.getTenfile(); //Lưu tên tập tin
                
                for (int i = 0; i < fInfo.getSochunk(); i++) {
                    fi = new FileInputStream(ThongTinChunk.duongDanChunk + tenfile + "/" + tenfile + "_" + (i + 1) + ".chunk");
                    int readsize = fi.read(buffer);
                    fi.close();
                    fo.write(buffer, 0, readsize);

                    event._value = i + 1;
                    LogFile.Write("Noi chunk #" + i);

                    //Phát sinh sự kiện đang ghép tập tin
                    Enumeration e = targets.elements();
                    while (e.hasMoreElements()) {
                        CustomEventListener l = (CustomEventListener) e.nextElement();
                        l.onOccur(event);
                    }
                }

                fo.flush();
                
                //Phát sinh sự kiện cắt tập tin hoàn tất
                Enumeration e = targets.elements();
                while (e.hasMoreElements()) {
                    CustomEventListener l = (CustomEventListener) e.nextElement();
                    l.onFinish(event);
                }
                
                LogFile.Write("Noi thanh cong " + ThongTinChunk.duongDanLuuFileGhep + tenfile + "/" + tenfile);

            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Lỗi\n\n" + ex.getMessage());
            LogFile.Write("!ERROR: " + ex.getMessage());
        } finally {
            try {
                fo.close();
            } catch (IOException ex) {
                Logger.getLogger(ThongTinTapTin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        LogFile.Write("#END Noifile()");
    }