def loadClick(self,e): returnVal = self._fc.showOpenDialog(self._splitpane) if returnVal == JFileChooser.APPROVE_OPTION: warning = """ CAUTION: Loading a saved configuration deserializes data. This action may pose a security threat to the application. Only proceed when the source and contents of this file is trusted. Load Selected File? """ result = JOptionPane.showOptionDialog(self._splitpane, warning, "Caution", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, None, ["OK", "Cancel"],"OK") if result != JOptionPane.YES_OPTION: return f = self._fc.getSelectedFile() fileName = f.getPath() ins = ObjectInputStream(FileInputStream(fileName)) dbData=ins.readObject() ins.close() self._db.load(dbData,self) self._userTable.redrawTable() self._messageTable.redrawTable()
def deserializeTree(filename): ''' For testing purposes, load & print a Java object parsetree. ''' filein = FileInputStream(filename) oostream = ObjectInputStream(filein) jtree = oostream.readObject() oostream.close() f = open(filename + ".debug", 'w') deepstr = pprint.pformat(jtree, indent=4, width=80) f.write("TESTING JAVA OBJ:\n" + str(deepstr) + '\n') f.close()
def deserialize(filepath): f = None o = None obj = None try: f = FileInputStream(filepath) o = ObjectInputStream(f) obj = o.readObject() except: syncPrintQ(sys.exc_info()) finally: if f: f.close() if o: o.close() if obj is None: syncPrintQ("Failed to deserialize object at " + filepath) return obj
def readInstanceList(fname): s = ObjectInputStream(FileInputStream(fname)) instances = s.readObject() s.close() return instances
def loadModel(file): s = ObjectInputStream(FileInputStream(file)) crf = s.readObject() s.close() return crf