📄 transferbothupl.java
字号:
import java.io.BufferedOutputStream;
import java.io.OutputStream;
import org.apache.commons.net.ftp.FTPClient;
public class TransferBothUpL extends Thread{
FTPClient ftpupl;
WByte wbyte1;
WByte wbyte2;
WByte wbyte3;
WByte wbyte4;
OutputStream foutupl;
BufferedOutputStream boutupl;
String filename;
long waitupl;
TransferBothUpL(WByte wbyte1,WByte wbyte2,WByte wbyte3,WByte wbyte4,FTPClient ftpupl,String filename){
this.wbyte1 = wbyte1;
this.wbyte2 = wbyte2;
this.wbyte3 = wbyte3;
this.wbyte4 = wbyte4;
waitupl = 0;
this.filename = filename;
this.ftpupl = ftpupl;
try{
foutupl = ftpupl.appendFileStream(filename);
boutupl = new BufferedOutputStream(foutupl);
}catch(Exception e){
System.out.println("error occur when open stream in upload.");
}
}
// 上传缓冲区的数据
public void run(){
while(wbyte1.flag_over != 1 && wbyte2.flag_over != 1 && wbyte3.flag_over != 1 &&wbyte4.flag_over != 1){
// if(wbyte1.flag_busy == 0 && wbyte1.flag_empty == 0){
if(wbyte1.flag_empty == 0){
try{
// System.out.println("buf1 is uploading.");
// wbyte1.flag_busy = 1;
boutupl.write(wbyte1.buf,0,wbyte1.length);
boutupl.flush();
wbyte1.flag_empty = 1;
// wbyte1.flag_busy = 0;
}catch(Exception e){
System.out.println("error occur when buf1 is uploading.");
}
}
// if(wbyte2.flag_busy == 0 && wbyte2.flag_empty == 0){
if(wbyte2.flag_empty == 0){
try{
// System.out.println("buf2 is uploading.");
// wbyte2.flag_busy = 1;
boutupl.write(wbyte2.buf,0,wbyte2.length);
boutupl.flush();
wbyte2.flag_empty = 1;
// wbyte2.flag_busy = 0;
}catch(Exception e){
System.out.println("error occur when buf2 is uploading.");
}
}
// if(wbyte3.flag_busy == 0 && wbyte3.flag_empty == 0){
if(wbyte3.flag_empty == 0){
try{
// System.out.println("buf3 is uploading.");
// wbyte3.flag_busy = 1;
boutupl.write(wbyte3.buf,0,wbyte3.length);
boutupl.flush();
wbyte3.flag_empty = 1;
// wbyte3.flag_busy = 0;
}catch(Exception e){
System.out.println("error occur when buf3 is uploading.");
}
}
// if(wbyte4.flag_busy == 0 && wbyte4.flag_empty == 0){
if(wbyte4.flag_empty == 0){
try{
// System.out.println("buf4 is uploading.");
// wbyte4.flag_busy = 1;
boutupl.write(wbyte4.buf,0,wbyte4.length);
boutupl.flush();
wbyte4.flag_empty = 1;
// wbyte4.flag_busy = 0;
}catch(Exception e){
System.out.println("error occur when buf4 is uploading.");
}
}
// System.out.println("UPL do nothing.");
waitupl++;
}
// if(wbyte1.flag_over == 1 && wbyte2.flag_empty == 0)
// try{
// boutupl.write(wbyte2.buf,0,wbyte2.length);
// }catch(Exception e){
// System.out.println("error when overing.");
// }
// if(wbyte2.flag_over == 1 && wbyte1.flag_empty == 0)
// try{
// boutupl.write(wbyte1.buf,0,wbyte1.length);
// }catch(Exception e){
// System.out.println("error when overing.");
// }
// while(wbyte1.flag_empty == 0 || wbyte2.flag_empty == 0 || wbyte3.flag_empty ==0 || wbyte4.flag_empty == 0){
if(wbyte1.flag_empty == 0 && wbyte1.flag_over != 1)
try{
boutupl.write(wbyte1.buf,0,wbyte1.length);
}catch(Exception e){
System.out.println("error when overing.");
}
if(wbyte2.flag_empty == 0 && wbyte2.flag_over != 1)
try{
boutupl.write(wbyte2.buf,0,wbyte2.length);
}catch(Exception e){
System.out.println("error when overing.");
}
if(wbyte3.flag_empty == 0 && wbyte3.flag_over != 1)
try{
boutupl.write(wbyte3.buf,0,wbyte3.length);
}catch(Exception e){
System.out.println("error when overing.");
}
if(wbyte4.flag_empty == 0 && wbyte4.flag_over != 1)
try{
boutupl.write(wbyte4.buf,0,wbyte4.length);
}catch(Exception e){
System.out.println("error when overing.");
}
// }
try{
boutupl.close();
foutupl.close();
}catch(Exception e){
System.out.println("error occur when close stream in upl.");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -