Java gets the system path font gets all the file names in a directory and gets the current path
- 2020-04-01 03:10:48
- OfStack
Java gets the system path font, gets all the file names in a directory, and gets the current path
package com.liuxing.test;
import java.awt.GraphicsEnvironment;
import java.io.File;
public class Test {
private static GraphicsEnvironment environment;
public static void main(String[] args) {
environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fonts = environment.getAvailableFontFamilyNames();//Gets the system font name
for(int i = 0;i<fonts.length;i++){
System.out.println(fonts[i]);
}
File file=new File("E:\QQImage");//Gets all the file names in a directory
String test[];
test=file.list();
for(int i=0;i<test.length;i++)
{
System.out.println(test[i]);
}
System.out.println(" In the current directory =="+System.getProperty("user.dir"));//Get the current path
}
}