/*

 * Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM)

 * Published By SunSoft Press/Prentice-Hall

 * Copyright (C) 1996 Sun Microsystems Inc.

 * All Rights Reserved. ISBN 0-13-565755-5

 *

 * Permission to use, copy, modify, and distribute this 

 * software and its documentation for NON-COMMERCIAL purposes

 * and without fee is hereby granted provided that this 

 * copyright notice appears in all copies. 

 * 

 * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR 

 * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER 

 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 

 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 

 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS

 * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED 

 * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 

 * THIS SOFTWARE OR ITS DERIVATIVES.

 */

 

/**

 * @version 1.00 07 Feb 1996 

 * @author Cay Horstmann

 */



import java.io.*;

import java.util.*;



public class DirStack

{  public static void main(String[] args)

   {  Stack dirs = new Stack();

      dirs.push(new File(File.separator + "."));

      while (dirs.size() > 0)

      {  File f = (File)dirs.pop();

         System.out.println(f);      

         String[] s = f.list();

         if (s != null)

         {  for (int i = 0; i < s.length; i++)

            {  File d = new File(f.getAbsolutePath() 

               + File.separator + s[i]);

               if (d.isDirectory())         

                  dirs.push(d);

            }

         }

      }

   }

}


