use resource file in jar

Posted tonggc1668

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了use resource file in jar相关的知识,希望对你有一定的参考价值。

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;

try {
      InputStream stream = getClass().getClassLoader().getResourceAsStream("a.html");
      return IOUtils.toString(stream, StandardCharsets.UTF_8);
    } catch (IOException e) {
      return e.toString();
    }

 

以上是关于use resource file in jar的主要内容,如果未能解决你的问题,请参考以下文章

Several ports (8005, 8080, 8009) required by Tomcat v8.5 Server at localhost are already in use.(示例代

node----DeprecationWarning: current URL string parser is deprecated和Port 3000 is already in use的问题(代

Linux 下启动idea-IU时报错 :Error opening zip file or JAR manifest missing: ../ jetbrains-agent.jar 的解决方法(代

GO 智能合约cannot use transactionRecordId + strconv.Itoa(id) (type string) as type byte in append(示例代码(代

错误记录Mac 中 Python 报错 ( ERROR: Could not build wheels for numpy which use PEP 517 and cannot be in )(代

Electron-builder“The process cannot access the file because it is being used by another process.”((代