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();
    }

 

posted @ 2020-04-09 11:50  tonggc1668  阅读(123)  评论(0编辑  收藏  举报