用jsp File browser,
http://www.vonloesch.de/jspbrowser.html

解决方案 »

  1.   

    java里面的File类可以实现的,嵌到jsp就可以
      

  2.   

    public class DeliveryUtil
    {
        public DeliveryUtil()
        {
        }    public static final String OctalHexNoZero =  "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[1-9])";
        public static final String OctalHex = "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])";    /**
         * Copy file to another place.
         * @param sourceFilePath String
         * @param destFilePath String
         */
        private static boolean CopyFile(String sourceFilePath, String destFilePath)
        {
            File sourceFile = new File(sourceFilePath);
            BufferedInputStream fin = null;
            BufferedOutputStream fout = null;        try
            {
                fin = new BufferedInputStream(new FileInputStream(sourceFile));
                fout = new BufferedOutputStream(new FileOutputStream(destFilePath));
                byte[] b = new byte[1024];
                int len = 0;
                while ( (len = fin.read(b)) != -1)
                {
                    fout.write(b, 0, len);
                }
            }
            catch (IOException ex)
            {
                ex.printStackTrace();
                return false;
            }
            finally
            {
                try
                {
                    fin.close();
                    fout.close();
                }
                catch (IOException ex)
                {
                    return false;
                }
            }
          return true;
        }    /**
         * Copy file to another place.
         * @param sourceFilePath String
         * @param destFilePath String
         * @throws IOException
         */
        public static boolean XCopyDir(String sourceDir, String destDir)
        {
            File source = new File(sourceDir);
            File dest = new File(destDir);        if(!source.isDirectory())
            {
                throw new IllegalArgumentException("invalid source directory path,path="+sourceDir);
            }
            if(!dest.exists()&&!dest.mkdirs())
            {
                UspLog.error("create dir error,dir="+dest);
                return false;
            }
            File[] files = source.listFiles();
            String destPath = null;
            for(int i=0;i<files.length;i++)
            {
                destPath = destDir+"\\"+files[i].getName();
                boolean isExists = new File(destPath).exists();
                if(files[i].isFile()&&!isExists)
                {
                    if(!CopyFile(files[i].getPath(), destPath))
                    {
                        UspLog.error("copy file error,file="+files[i].getPath()+",destpath="+destPath);
                        return false;
                    }
                }
                else if(files[i].isDirectory()&&!isExists)
                {
                    if(!XCopyDir(files[i].getPath(),destPath))
                        return false;
                }
            }
            return true;
        }    /**
         * Copy file to another place.
         * @param sourceFilePath String
         * @param destFilePath String
         * @throws IOException
         */
        private static boolean XCopyDirWithCMD(String sourceDirPath, String destDirPath)
        {        String command = "xcopy " + sourceDirPath + " " + destDirPath + " /e /s /i";
            try
            {
                Process proc = Runtime.getRuntime().exec(command);
                /* Causes the current thread to wait, if necessary,
                 until the process represented by this Process object has terminated.
                 */            if (proc.waitFor() != 0)
                {
                    // Return the exit value for the process,the value 0 indicates normal
                    //  termination.                if ( (proc.exitValue()) != 0)
                    {
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }    private static boolean DeleteFile(String filePath)
        {
            File file = new File(filePath);
            if (file.exists())
            {
                return file.delete();
            }
            else
            {
                return false;
            }
        }    public static boolean XDeleteDir(String dirPath)
        {
            File dir = new File(dirPath);
            if(!dir.isDirectory())
            {
                return false;
            }
            File[] files = dir.listFiles();        for(int i=0;i<files.length;i++)
            {
                if(files[i].isFile())
                {
                    if(!files[i].delete())
                    {
                        UspLog.error("delete file error,file="+files[i]);
                        return false;
                    }
                }
                else if(files[i].isDirectory())
                {
                    if(!XDeleteDir(files[i].getPath()))
                        return false;
                }
            }
            return dir.delete();
        }
    }