import java.net.*; import java.io.*; import java.awt.List; import javax.swing.JFrame; import javax.swing.JOptionPane; /* * 该类实现文件的接受功能 * 默认的端口是9998 */ public class FileReceiver extends Thread { int port=9900; String fileName; List chatContentList; boolean isOver=false; ServerSocket ss=null; long count; public FileReceiver(String fileName,List chatContentList) { this.fileName=fileName; this.chatContentList=chatContentList; } public void run() { BufferedOutputStream bos=null; BufferedInputStream bis=null; try { ss=new ServerSocket(port); Socket s=ss.accept(); bos=new BufferedOutputStream(new FileOutputStream(fileName)); bis=new BufferedInputStream(s.getInputStream()); byte[] buf=new byte[1024]; int i=0; while((i=bis.read(buf,0,1024))!=-1) { count+=1024; ClientFrame.bar.setValue ((int)(count)/1024); bos.write(buf,0,i); bos.flush(); } bis.close(); s.close(); bos.close(); ss.close(); JOptionPane.showMessageDialog(null, "接受文件成功!", "提示",JOptionPane.INFORMATION_MESSAGE); ClientFrame.bar.setVisible(false); ClientFrame.jLabel5.setText(""); ClientFrame.filelength=0; } catch (Exception ex) { ex.printStackTrace(); } } public void setOver(boolean over) { this.isOver=over; } }

游弋time1105 LV1
2024年5月15日
微信网友_6444139264921600 LV8
2023年4月29日
Sopuding LV1
2022年7月16日
tomtom113 LV2
2022年6月9日
ewan007 LV30
2022年4月21日
tdcq123 LV14
2022年3月13日
双方各何必呢 LV13
2021年12月20日
曹思辰 LV6
2021年11月21日
阳光正好 LV2
2021年10月29日
1005948011 LV7
2021年6月1日

krispeng LV15
5月23日
13133117021 LV5
2024年12月24日
yzj880427
2024年10月12日
暂无贡献等级
444105047 LV6
2024年6月25日
taoshen95 LV16
2024年6月18日
微信网友_6813145916592128
2024年5月7日
暂无贡献等级
ntboss2002 LV3
2024年5月3日
1112WHQ LV7
2023年11月3日
yuchunxing LV1
2023年9月2日
2017143155 LV12
2023年6月24日