Article View: cn.bbs.comp.lang.java
Article #19175Re: �������HashTable�IJ�����
From: Castor Pollux
Date: Sat, 10 Jan 2004 04:17
Date: Sat, 10 Jan 2004 04:17
38 lines
2181 bytes
2181 bytes
import java.io.*;
import java.util.*;
class HashTableTest {
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
Hashtable ht = new Hashtable();
ht.put(new Integer(1), "One"); ht.put(new Integer(2), "Two"); ht.put(new Integer(3), "Three");
// write to a file named "theHashtable"
FileOutputStream fos = new FileOutputStream("theHashtable");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(ht);
oos.flush();
oos.close();
fos.close();
// read from the file named "theHashtable"
FileInputStream fis = new FileInputStream("theHashtable");
ObjectInputStream ois = new ObjectInputStream(fis);
Hashtable newHt = (Hashtable)ois.readObject();
ois.close();
fis.close();
System.out.println(ht);
System.out.println(newHt);
System.out.println(newHt.equals(ht));
}
}
�� �� ASoriano@bbs.pku.edu.cn (��12���dz������ݡ�) �Ĵ������ᵽ: ��
: ��ô��HashTableд���ļ���
: ���һ��ܶ���������
: д���ļ��ĸ�ʽ����ν��ֻҪ���ٶ�������
--
[m[1;34m�� ��Դ:���ɽ��ˮ bbs.neu.edu.cn��[FROM: 202.118.7.156][m
Technical Details
Message-ID:
<4ACZ9X$Bip@bbs.neu.edu.cn>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.webusenet.com!maily.cic.tsinghua.edu.cn!news.neu.edu.cn!NEUShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,GB X-Google-Thread: f6cb0,4a1487f7cf7db6a3 X-Google-Attributes: gidf6cb0,public X-Google-ArrivalTime: 2004-01-09 20:18:14 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.webusenet.com!maily.cic.tsinghua.edu.cn!news.neu.edu.cn!NEU From: Dioscuri.bbs@bbs.neu.edu.cn (Castor Pollux) Newsgroups: cn.bbs.comp.lang.java Subject: Re: �������HashTable�IJ����� Date: 10 Jan 2004 04:17:28 GMT Organization: ��ɽ��ˮ Message-ID: <4ACZ9X$Bip@bbs.neu.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: java/M.1073708241.A Lines: 38