⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writeobject.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
import java.io.*;import java.util.*;// This class writes out a date object and a hash table object// to a file called "writeme" using an ObjectOutputStream.public class WriteObject{  public static void main( String[] args )  {    // Create a hash table with a few entries    Hashtable writeHash = new Hashtable();    writeHash.put("Leader", "Moe");    writeHash.put("Lieutenant", "Larry");    writeHash.put("Stooge", "Curly");    try    {      // Create an output stream to a file called "writeobject.txt"      FileOutputStream fileOut = new FileOutputStream( "writeobject.txt" );      // Open an output stream filter on the file stream      ObjectOutputStream objOut = new ObjectOutputStream( fileOut );      // Write out the current date and the hash table      objOut.writeObject( new Date() );      objOut.writeObject( writeHash );      // Close the stream      objOut.close();     }     catch ( IOException ex )     {        ex.printStackTrace();     }   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -