Start Search Contents Index Links About
IEBookmarks.java
/*
 * Author: Havard Rast Blok
 * E-mail: 
 * Web   : www.rememberjava.com
 */


import java.io.*;
import javax.swing.*;
import javax.swing.tree.*;

/**
 * Class for parsing and showing the 
 * Internet Explorer favourites
 */
public class IEBookmarks extends JFrame
{
  String urlTag="URL=";

  public IEBookmarks(String path)
  {
    DefaultMutableTreeNode root;
    DefaultTreeModel treeModel;
    JTree tree;

    //make the tree
    root = new DefaultMutableTreeNode("Bookmarks");

    addNodenew File(path), root );

    treeModel = new DefaultTreeModel(root);
    tree = new JTreetreeModel );
   
    getContentPane().addtree );

    setDefaultCloseOperationJFrame.EXIT_ON_CLOSE );
    pack();
    show();

  }

  private void addNodeFile path, DefaultMutableTreeNode root )
  {
    DefaultMutableTreeNode node;
    File fileList[];
    String fName, link;

    fileList = path.listFiles();

    //if the list is null, the path was not a directory,
    //or could not be read
    iffileList != null )
    {
      forint i=0; i<fileList.length; i++)
      {
  fName = fileList[i].getName();
  node = new DefaultMutableTreeNodefName );
  iffileList[i].isFile() )
  {
    fName = fName.substring(0, fName.length()-4);
    link = getLinkfileList[i] );
    node.setUserObjectfName+" ("+link+")" );
  }
  root.addnode );

  addNodefileList[i], node );
      }
    }
  }

  private String getLinkFile fName )
  {
    String ans;
    BufferedReader in;
    String line;
    int index;

    ans = "";
    
    try
    {
      in = new BufferedReadernew FileReaderfName ) );
      while( ( line = in.readLine() ) != null && ans.length() == )
      {
  index = line.indexOfurlTag );
  ifindex != -)
  {
    ans = line.substringindex+urlTag.length() );
  }
      }
      in.close();
    }
    catchIOException e )
    {
      System.out.println("IEBookmarks.getLink - error reading file: "+e);
    }

    return ans;
  }    

  public static void mainString args[] )
  {
    ifargs.length < )
    {
      System.out.println("Usage: java IEBookmarks <Explorer favourites directory>");
      System.exit(1);
    }

    new IEBookmarks(args[0]);
  }
}
    


site: Håvard Rast Blok
mail:
updated: 27 July 2007