📄 clientio.java
字号:
import java.io.*;
public class ClientIO{
//private static String friendsFile="clientFriendsDatabase";
//private static ObjectOutputStream oos=null;
//private static ObjectInputStream ois=null;
/* called by connectServer() in ClientControlThread;
* if no key match the client's id,then the client is new-user
* on the system in this computer,then setup a new database for
* it. if there is a matching key,then load the database
*/
/*static FriendsDatabase readFriendsDatabase(long key){
FriendsDatabase fd=null;
if(!checkFile(friendsFile+String.valueOf(key))) //if file doesn't exit
return new FriendsDatabase(key); //return new database
else{
if((fd=(FriendsDatabase)readFromDatabase(friendsFile+String.valueOf(key)))!=null){
return fd;
}
return new FriendsDatabase(key); //return new database
}
}
static void writeFriendsDatabase(Object o,String fileName){
writeToDatabase(o,fileName);
}
static boolean checkFile(String fileName){ // to check if none of data has been written in
File temp=new File(fileName);
boolean signal=temp.exists();
if(!signal) //file doesn't exit,the initial status
return false;
else return true;
}*/
static int getInt(){
return Integer.parseInt(getString());
}
static long getLong(){
return Long.parseLong(getString());
}
static String getString(){
BufferedReader br;
br=new BufferedReader(new InputStreamReader(System.in));
try{
return br.readLine();
}
catch(IOException e){
System.out.println(e+" "+e.getMessage());
return null;
}
}
/*private static void writeToDatabase(Object end,String fileName){
try{
oos=new ObjectOutputStream(
new FileOutputStream(fileName));
oos.writeObject(end);
oos.flush();
oos.close();
}
catch(IOException e){
System.out.println(e+" "+e.getMessage());
}
}
private static Object readFromDatabase(String fileName){
try{
ois=new ObjectInputStream(new FileInputStream(fileName));
Object o=ois.readObject();
ois.close();
return o;
}
catch(Exception e){
System.out.println(e+" "+e.getMessage());
return null;
}
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -