我有一个 .jar 文件,其名称为 stanford-parser-2.0.4-models。 解压后得到的是englishPCFG.ser文件。
有人可以建议如何查看该文件的内容吗,因为使用我的程序员记事本和gedit,我在该文件中只能查看一些外来符号和二进制代码。 目前我对 ser 文件一无所知。
预先感谢您在这方面的任何帮助。
最佳答案
当您想要反序列化文件时。查找下面的代码片段:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
public class ReadFile{
int i=0;
public static void main(String args[]){
File f = new File(args[0]);
try{
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(f));
System.out.println("The text : "+ obj.readObject());
obj.close();
System.out.println("Deserializing Operation Completly Successfully.");
}
catch(ClassNotFoundException e){
System.out.println(e.getMessage());
}
catch(FileNotFoundException fe){
System.out.println("File not found ");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
}
将上面的代码放在ReadFile.java的文件名中 要编译你的代码,请谷歌它。我不能给你所有的东西:(
关于java - 查看解压.jar文件得到的.ser文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15450196/