📄 filemanage.java
字号:
package edu.test.demo;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class FileManage {
public static void addObject(Object o,String filename) throws IOException
{ File f=new File(filename);
FileOutputStream fos=new FileOutputStream(f);
ObjectOutputStream os=new ObjectOutputStream(fos);
try
{
os.writeObject(o);
os.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static Object findObject(String filename) throws IOException
{File f=new File(filename);
Object o=null;
FileInputStream fos=new FileInputStream(f);
ObjectInputStream os=new ObjectInputStream(fos);
try
{
o=os.readObject();
os.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return o;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -