gpt4 book ai didi

java - 从资源文件夹加载字体文件

转载 作者:太空宇宙 更新时间:2023-11-04 14:25:47 25 4
gpt4 key购买 nike

我尝试加载资源文件夹中的字体文件:

URL url = this.getClass().getResource("/com/fuentes/fuente.ttf");
File file = new File(url.toURI());
newFont = PDTrueTypeFont.loadTTF(documento, file);

但我收到此错误:

URI is not hierarchical

最佳答案

试试这个:

File file = new File(this.getClass().getResource("/com/fuentes/fuente.ttf").getFile());

关于java - 从资源文件夹加载字体文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26677322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com