Article View: cn.bbs.comp.lang.java
Article #19174Re: �������HashTable�IJ�����
From: Castor Pollux
Date: Sat, 10 Jan 2004 04:14
Date: Sat, 10 Jan 2004 04:14
32 lines
1987 bytes
1987 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();
// read from the file named "theHashtable"
FileInputStream fis = new FileInputStream("theHashtable");
ObjectInputStream ois = new ObjectInputStream(fis);
Hashtable newHt = (Hashtable)ois.readObject();
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:
<4ACZ4Q$Ca_@bbs.neu.edu.cn>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!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:15:07 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!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:14:05 GMT Organization: ��ɽ��ˮ Message-ID: <4ACZ4Q$Ca_@bbs.neu.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: java/M.1073707994.A Lines: 32