0
나는 JAR
에 넣을 때까지 작업 한 다음 코드File 객체를 사용하여 리소스에 액세스 할 수 있습니까?
try {
URL url = getClass().getResource("");
log.debug("url = '{}'", url.toString());
URI uri = url.toURI();
log.debug("uri = '{}'", uri.toString());
File dir = new File(uri);
files = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".ttf");
}
});
indice = new Integer[files.length];
delegate = new Descr[files.length];
fileNames = new String[files.length];
fontNames = new String[files.length];
for(int i=0; i<files.length; ++i) {
delegate[i] = new Descr(Font.createFont(Font.TRUETYPE_FONT, files[i]).deriveFont(FontSize));
fileNames[i] = files[i].getName();
fontNames[i] = delegate[i].getFont().getFontName();
}
} catch (URISyntaxException e) {
throw new AssertionError(e);
} catch (FontFormatException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
와 폰트 자원에 접근했다. 그것이 원인이 JAR
및 오류
IllegalargumentException: URI is not hierarchicalhierarchical
에서 그럼, 어떻게 JAR
내부 자원을 열거하려면? File
을 사용할 수 있습니까?
물론 생성이 불가능한 경우 목록을 하드 코딩합니다. 필자의 경우이 글꼴은 글꼴이며 새 글꼴을 쉽게 추가 할 수 있습니다. –
의견이 있으십니까? 그렇다면 그것은 내게 없어졌습니다. –