Skip to content

Instantly share code, notes, and snippets.

@TheLouisHong
Last active December 22, 2015 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheLouisHong/6391940 to your computer and use it in GitHub Desktop.
Save TheLouisHong/6391940 to your computer and use it in GitHub Desktop.
A program that reads unknown Serialized objects, with problems,.....
package com.louishong;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.lang.reflect.Field;
public class ReadFile{
int i=0;
public static void main(String args[]){
File f = new File(args[0]);
try{
ObjectInputStream objStream = new ObjectInputStream(new FileInputStream(f));
Object obj = objStream.readObject();
Class<?> clazz = obj.getClass();
System.out.println(clazz.getName());
objStream.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();
}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment