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

源代码在线查看: e044. serializing an object.txt

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

相关代码

				The object to be serialized must implement java.io.Serializable. This example serializes a javax.swing.JButton object. 
				See also e45 Deserializing an Object. 
				
				    Object object = new javax.swing.JButton("push me");
				    
				    try {
				        // Serialize to a file
				        ObjectOutput out = new ObjectOutputStream(new FileOutputStream("filename.ser"));
				        out.writeObject(object);
				        out.close();
				    
				        // Serialize to a byte array
				        ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
				        out = new ObjectOutputStream(bos) ;
				        out.writeObject(object);
				        out.close();
				    
				        // Get the bytes of the serialized object
				        byte[] buf = bos.toByteArray();
				    } catch (IOException e) {
				    }
							

相关资源