JCodeModel (SUN)에 문제가 있습니다. 내 프로그램이 매일 실행되고 있는데, 을 추가하려면을 현재 실행 이전에 생성 된 클래스에 추가하십시오.종료 후 Jcodemodel 객체 저장
JcodeModel이 (가) 지원합니까? 그렇지 않은 경우 JCodemodel Object를 외부 파일에 저장하고 이전 JcodeModel을로드 한 다음 새 함수를 추가하는 옵션이 있습니까?
감사합니다.
JCodeModel (SUN)에 문제가 있습니다. 내 프로그램이 매일 실행되고 있는데, 을 추가하려면을 현재 실행 이전에 생성 된 클래스에 추가하십시오.종료 후 Jcodemodel 객체 저장
JcodeModel이 (가) 지원합니까? 그렇지 않은 경우 JCodemodel Object를 외부 파일에 저장하고 이전 JcodeModel을로드 한 다음 새 함수를 추가하는 옵션이 있습니까?
감사합니다.
ObjectOutputStream을 사용하여 인스턴스를 파일로 저장 한 다음 ObjectInputStream을 사용하여 인스턴스를 읽고 인스턴스화 할 수 있습니다. 시스템을 제어하고 버전이 밤새 바뀌지 않는지 확인하는 한, 안전해야합니다 (특이 함).
그것을 사용하는 방법을 보여줍니다import java.io.*;
public class ObjectOutputStreamDemo {
public static void main(String[] args) {
String s = "Hello world!";
int i = 897648764;
try {
// create a new file with an ObjectOutputStream
FileOutputStream out = new FileOutputStream("test.txt");
ObjectOutputStream oout = new ObjectOutputStream(out);
// write something in the file
oout.writeObject(s);
oout.writeObject(i);
// close the stream
oout.close();
// create an ObjectInputStream for the file we created before
ObjectInputStream ois =
new ObjectInputStream(new FileInputStream("test.txt"));
// read and print what we wrote before
System.out.println("" + (String) ois.readObject());
System.out.println("" + ois.readObject());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
예외가 발생했습니다 : java.io.NotSerializableException : com.sun.codemodel.JCodeModel –
.... JCodeModel이 Serializable이 아닙니다 ... 나쁘다면, 작동하지 않습니다 ... 죄송합니다! –
당신이 JCodeModel를 통해에 기능을 추가 할 원래의 클래스를 생성하는 프로그램인가? –
@ johncarl : 예. –
원래 프로그램에서 생성 한 프로그램은 무엇입니까? IE : 코드를 생성하는 방법을 지시하는 모델 또는 설명자에서 프로그램을 읽습니까? –