将计算机C盘下保存的字体信息用JAVA语言输出文件名信息代码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错误!");
    }
    }
}

相关文章:

  • 2021-12-30
  • 2021-08-18
  • 2022-12-23
  • 2023-04-05
  • 2021-12-02
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-01-06
  • 2021-08-11
相关资源
相似解决方案