본문 바로가기

Program/Java

If ObjectInputStream Package Name has been changed

** 개인적 메모입니다. 태클 사절 **

public class CustomObjInputStream extends ObjectInputStream {
	private static final Logger logger = Logger.getLogger(CustomObjInputStream.class);

	protected CustomObjInputStream() throws IOException, SecurityException {
		super();
	}

	public CustomObjInputStream(InputStream in) throws IOException {
		super(in);
	}

	@Override
	protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
		ObjectStreamClass read = super.readClassDescriptor();
		logger.debug("read = " + read);
		logger.debug("read.getName() = " + read.getName());
		logger.debug("read.getSerialVersionUID() = " + read.getSerialVersionUID());
		logger.debug("read.read.getFields() = " + read.getFields());

		if (read.getName().startsWith("com.test.code.object.")) {
			return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.test.code.object.", "com.test.code1.object.")));
		}

		return read;
	}

}


'Program > Java' 카테고리의 다른 글

Java의 URL에서 파일 다운로드  (0) 2022.07.28
[JAVA] Comparator  (0) 2012.03.16
Eclipse Properites Editor  (0) 2012.01.05
Eclipse - .svn delete  (1) 2012.01.03
Compile recursively with javac  (1) 2011.12.30