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

📄 bookmarklist.java

📁 书籍"Java_面向事件编程"的附带光盘代码
💻 JAVA
字号:
import java.io.*;// class to handle a list of bookmarks// the bookmarks can be saved to a filepublic class BookmarkList {    private EmptyBookmarks list;  // the list of bookmarks    public BookmarkList( ){        list = new EmptyBookmarks();    }    // return the number of bookmarks in the list    public int size( ){        return list.getSize();    }    // return the bookmark at index     public Bookmark getSelectedItem( int index ){        return list.getSelectedItem( size() - (index + 1) );    }        // add a bookmark to the list    public void add( Bookmark entry ){        list = list.add(entry);    }        // Print all bookmark entries    public void printBookmarks()    {        for ( int i = 0; i < size(); i++) {            System.out.println( getSelectedItem(i).toString() );        }    }        // Place all bookmark entries in bookmarks.html    public void saveBookmarksFile() {                try {            FileWriter bookmarksFile = new FileWriter("bookmarks.html");                        for ( int i = 0; i < size(); i++) {                bookmarksFile.write( getSelectedItem(i).toString());            }                        bookmarksFile.close();        } catch ( IOException e) {            System.out.println("Unable to access bookmarks file - " + e.getMessage());         }    }        }

⌨️ 快捷键说明

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