首页 > 学院 > 开发设计 > 正文

java.IO搜索指定文件

2019-11-17 04:01:53
字体:
来源:转载
供稿:网友
最近很郁闷,我的本本莫名其妙的中了一种嵌入式病毒,磁盘上的所有asp和html文件的结尾都加上了一句<iframe src=http://mm.uu88567.cn/index/mm.htm width=100 height=0></iframe>TMD那个不要脸的,为了刷流量干出这么损人的招

哎,么办法,出了问题,那就解决问题吧。今天写了一个读取文件的类可是就是忘了,怎么用流读取文件呢?

                          view plaincopy to clipboardPRint?
package org.zhang.io;   
  
import java.io.*;   
  
public class IOTest {   
    public static void main(String[] args) throws Exception {   
        fun("F://");   
    }   
  
    public static void fun(String dir) {   
        File f = new File(dir);   
        String[] str = null;   
        if (f.isDirectory()) {   
            str = f.list();   
            for (int i = 0; str != null && i < str.length; i++) {   
                fun(dir + File.separator + str[i]);   
            }   
        }else{   
            if (dir.endsWith("asp")) {   
                System.out.println(dir);   
            }   
        }   
    }   
}  
package org.zhang.io;

import java.io.*;

public class IOTest {
public static void main(String[] args) throws Exception {
fun("F://");
}

public static void fun(String dir) {
File f = new File(dir);
String[] str = null;
if (f.isDirectory()) {
str = f.list();
for (int i = 0; str != null && i < str.length; i++) {
fun(dir + File.separator + str[i]);
}
}else{
if (dir.endsWith("asp")) {
System.out.println(dir);
}
}
}
}

测试出指定路径下的指定文件。

修改所有文件暂时么实现。(未完)
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表