Created
September 15, 2017 07:43
-
-
Save shangoyanyi/02988c63dbe24dae2212ea9e2e62e5ef to your computer and use it in GitHub Desktop.
how to read resource in JavaEE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResourceReader{ | |
/* | |
* filePath 是檔案所在的 package ,將 "." 改為 "/" | |
* 例如檔案 config.txt 所在 package 是 my.resource | |
* 則 filePath = "my/resource/config.txt" | |
*/ | |
public void readResource(String filePath){ | |
InputStream in = ResourceReader.class.getClassLoader().getResourceAsStream(filePath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment