这里面包含了一百多个JAVA源文件

源代码在线查看: e045. deserializing an object.txt

软件大小: 551 K
上传用户: maple_78
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				This example deserializes a javax.swing.JButton object. 
				See also e44 Serializing an Object. 
				
				    try {
				        // Deserialize from a file
				        File file = new File("filename.ser");
				        ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
				        // Deserialize the object
				        javax.swing.JButton button = (javax.swing.JButton) in.readObject();
				        in.close();
				    
				        // Get some byte array data
				        byte[] bytes = getBytesFromFile(file);
				        // see e36 Reading a File into a Byte Array for the implementation of this method
				    
				        // Deserialize from a byte array
				        in = new ObjectInputStream(new ByteArrayInputStream(bytes));
				        button = (javax.swing.JButton) in.readObject();
				        in.close();
				    } catch (ClassNotFoundException e) {
				    } catch (IOException e) {
				    }
				
							

相关资源