use resource file in jar

时间:2020-04-09 12:52:01   收藏:0   阅读:68
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();
    }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!