将计算机C盘下保存的字体信息用JAVA语言输出文件名信息代码

来源:互联网 发布:mac mysql客户端工具 编辑:程序博客网 时间:2024/06/06 21:02

import java.io.*;

class MyFonts {
    public static void main(String [] args){
    try {
        FileReader read = new FileReader("myfonts.txt"); //p289
        BufferedReader readFonts = new BufferedReader(read);  //291
        String regex = "[0-9+/0-9+/0-9].+";//格式为“年/月/日”+任意字符串
        String regexFileName = "\\s+";//代表1个或多个空格类字符
        String regex1= ".+[.].+";
        String str = null;
        //按行读取
        while((str = readFonts.readLine())!= null)//p291
        if(str.matches(regex)){
            String [] tmp = str.split(regexFileName);
            for(String str1 : tmp) {
            if(str1.matches(regex1))
                System.out.println(str1);
            }
        }
        readFonts.close();
    }
    catch(FileNotFoundException e) {
        System.out.println("文件myfonts.txt不存在!");
    }
    catch(IOException e) {
        System.out.println("发生IO错误!");
    }
    }
}
阅读全文
0 0
原创粉丝点击