Seb*_*_Lz 5 java load exception object save
我正在使用这种简单的方法在java中开发一个常规将对象保存到硬盘上的应用程序:
public void save(String filename)
{
try
{
FileOutputStream fos = new FileOutputStream(filename);
GZIPOutputStream gzos = new GZIPOutputStream(fos);
ObjectOutputStream out = new ObjectOutputStream(gzos);
out.writeObject(this);
out.flush();
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
该对象是sebbot.learning.DirectPolicySearch类的实例.
问题是,经过一些重构后,学习包被重命名为"ballcapture".现在,当我尝试加载保存的文件时,我得到以下异常:
java.lang.ClassNotFoundException:sebbot.learning.DirectPolicySearch
我用来加载文件的方法是:
public static synchronized DirectPolicySearch load(String filename)
{
DirectPolicySearch dps = null;
try
{
FileInputStream fis = new FileInputStream(filename);
GZIPInputStream gzis = new GZIPInputStream(fis);
ObjectInputStream in = new ObjectInputStream(gzis);
dps = (DirectPolicySearch) in.readObject();
in.close();
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println(dps);
return dps;
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我这个 ?非常感谢.
| 归档时间: |
|
| 查看次数: |
1816 次 |
| 最近记录: |