bookmarklist.java~

来自「书籍"Java_面向事件编程"的附带光盘代码」· JAVA~ 代码 · 共 53 行

JAVA~
53
字号
import java.io.*;// class to handle a list of bookmarkspublic 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 + =
减小字号Ctrl + -
显示快捷键?