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

📄 wanderer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
字号:
// **********************************************************************// // <copyright>// //  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000// //  Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/util/wanderer/Wanderer.java,v $// $RCSfile: Wanderer.java,v $// $Revision: 1.4.2.2 $// $Date: 2004/12/08 01:45:44 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.util.wanderer;import java.io.File;import com.bbn.openmap.util.ArgParser;import com.bbn.openmap.util.Debug;/** * A Wanderer is a class that traverses a directory tree and finds * files and directories. It then makes a method call on the * WandererCallback class to have something done on those directories * or files. */public class Wanderer {    WandererCallback callback = null;    public Wanderer() {    }    public Wanderer(WandererCallback callback) {        this();        this.callback = callback;    }    public void setCallback(WandererCallback cb) {        callback = cb;    }    public WandererCallback getCallback() {        return callback;    }    /**     * Given a file representing a top-level directory, start     * wandering the tree and call handleDirectory or handleFile on     * the WandererCallback.     *      * @param file File (directory) to start at.     */    public void handleEntry(File file) {        try {            String[] filenames = file.list();            boolean dirTest = false;            boolean not14 = false;            try {                java.lang.reflect.Method method = file.getClass()                        .getDeclaredMethod("isDirectory", (Class[])null);                Object obj = method.invoke(file, null);                if (obj instanceof Boolean) {                    dirTest = ((Boolean) obj).booleanValue();                }            } catch (NoSuchMethodException nsme) {                not14 = true;            } catch (SecurityException se) {                not14 = true;            } catch (IllegalAccessException iae) {                not14 = true;            } catch (IllegalArgumentException iae2) {                not14 = true;            } catch (java.lang.reflect.InvocationTargetException ite) {                not14 = true;            }            if (not14) {                dirTest = (filenames != null);            }            if (dirTest) {                // It's a directory...                handleDirectory(file, filenames);                callback.handleDirectory(file);            } else {                callback.handleFile(file);            }        } catch (NullPointerException npe) {        } catch (SecurityException se) {        }    }    public void handleDirectory(File directory, String[] contentNames)            throws SecurityException {        File[] contents = new File[contentNames.length]; // file.listFiles();        for (int i = 0; i < contents.length; i++)            contents[i] = new File(directory.getAbsolutePath() + File.separator, contentNames[i]);        for (int i = 0; i < contents.length; i++) {            handleEntry(contents[i]);        }    }    /**     * Given a set of files or directories, parade through them to     * change their case.     *      * @param argv paths to files or directories, use -h to get a     *        usage statement.     */    public static void main(String[] argv) {        Debug.init();        ArgParser ap = new ArgParser("Wanderer");        if (argv.length == 0) {            ap.bail("", true);        }        String[] dirs = argv;        Wanderer wanderer = new Wanderer(new TestWandererCallback());        // Assume that the arguments are paths to directories or        // files.        for (int i = 0; i < dirs.length; i++) {            wanderer.handleEntry(new File(dirs[i]));        }    }}

⌨️ 快捷键说明

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