📄 tofriendfile.java
字号:
//represent file to send to a friend
import java.io.File;
class ToFriendFile implements Comparable<ToFriendFile>{
private int id;
private File file;
//public FileToFriend(){}
public ToFriendFile(File file){
this.file=file;
id=ClientThread.getToFriendFileID();
}
public ToFriendFile(int id){
this.id=id;
}
public int compareTo(ToFriendFile tff){
boolean b=(id==tff.getID());
return (b==true ? 0 : id>tff.getID() ? 1 : -1);
}
public int getID(){
return id;
}
public File getFile(){
return file;
}
}
//represent file from a friend
class FromFriendFile implements Comparable<FromFriendFile>{
private int sendFileKey,receiveFileKey; //when receive a send-file request,assign it an receiveFileKey
private File file;
private String ip;
//public FileToFriend(){}
public FromFriendFile(File file,String ip,int sendFileKey){
this.file=file;
this.ip=ip;
this.sendFileKey=sendFileKey;
receiveFileKey=ClientThread.getFromFriendFileID();
}
public FromFriendFile(int receiveFileKey){
this.receiveFileKey=receiveFileKey;
}
public int compareTo(FromFriendFile fcf){
boolean b=(receiveFileKey==fcf.getID());
return (b==true ? 0 : receiveFileKey>fcf.getID() ? 1 : -1);
}
public int getID(){
return receiveFileKey;
}
public File getFile(){
return file;
}
public String getIP(){
return ip;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -