`
morning2008
  • 浏览: 112735 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
Java实现文件搜索 java
 /**
     * 
     * 搜索文件 <br> 
     *  
     * @author xiao.yuan <br>
     * @taskId <br>
     * @param dir 搜索目录
     * @param key 搜索的关键字
     * @param rule 搜索规则
     * @param searchHidden  是否搜索隐藏文件,false不搜索<br>
     */
    public static void searchFile(String dir,String key, String rule, boolean searchHidden)
    {
        File file = new File(dir);
        File[] fileList = file.listFiles();
        String fileName = "";
        String filePath = "";
        if (fileList == null || fileList.length == 0)
        {
            return;
        }
        for (File f : fileList)
        {
            // 不搜索隐藏文件
            if (!searchHidden && f.isHidden())
            {
                continue;
            }
            fileName = f.getName();
            filePath = f.getPath();
            if (f.isFile())
            {
                if (SearchRule.SUFFIX.equalsIgnoreCase(rule))
                {
                    
                    String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
                    if (suffix.equalsIgnoreCase(key))
                    {
                        System.out.println("file path -->" + filePath);
                        // 统计搜索到的文件数
                        FILE_NUM ++;
                        FILE_LIST.add(f);
                    }
                    
                }
            }
            else if (f.isDirectory())
            {
                searchFile(filePath, key, rule, searchHidden);
                // 统计搜索到的目录数
                DIR_NUM ++;
            }
        }   
        
    }
Java实现文件拷贝 java
 /**
     * 
     * [拷贝文件] <br> 
     *  
     * @author  <br>
     * @taskId <br>
     * @param toDir <br>
     */
    public static void copyFile(String toDir)
    {
        // FILE_LIST为需要拷贝的文件列表
        if (CollectionUtils.isEmpty(FILE_LIST))
        {
            return;
        }
        FileInputStream fis = null;
        BufferedInputStream bis = null;
        FileOutputStream fos = null;
        BufferedOutputStream bos = null;
        // 拷贝后的新文件名
        String newFile = "";
        try
        {
            for (File file : FILE_LIST)
            {
                fis = new FileInputStream(file);
                bis = new BufferedInputStream(fis);
               
                if (toDir.endsWith("\\"))
                {
                    newFile = toDir + file.getName();
                }
                else
                {
                    newFile = toDir + "\\" + file.getName();
                }
                // 指定目录不存在需要新建
                File newF = new File(toDir);
                if (!newF.exists())
                {
                    newF.mkdirs();
                }
                fos = new FileOutputStream(newFile);
                bos = new BufferedOutputStream(fos);
                int lentgh = 0;
                while ((lentgh = bis.read()) != -1)
                {
                    bos.write(lentgh);
                }
                bis.close();
                bos.close();
            } 
        }
        catch (IOException e)
        {
           throw new BaseAppException("Read File Error.");
        }
    }
查询Oracle数据库版本 oracle
--查询Oracle数据库版本
SELECT * FROM v$version;

--查询Oracle全局数据库名称
SELECT * FROM v$database;

--查询Oracle当前数据库实例SQL
SELECT * FROM v$instance; 
Global site tag (gtag.js) - Google Analytics