diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-04-11 17:51:13 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-04-11 17:51:13 -0400 |
| commit | 40858cee415643769ee5f6216b0cd4335996ff2f (patch) | |
| tree | 86b1c334fa2e5b79cddc16984f5ad43c3c72e41f /dice-lang/src/bjc/dicelang/util/ResourceLoader.java | |
| parent | 767ca1b248da19b754d42a814b71b43ef16090be (diff) | |
General cleanup and fixes
Diffstat (limited to 'dice-lang/src/bjc/dicelang/util/ResourceLoader.java')
| -rw-r--r-- | dice-lang/src/bjc/dicelang/util/ResourceLoader.java | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/dice-lang/src/bjc/dicelang/util/ResourceLoader.java b/dice-lang/src/bjc/dicelang/util/ResourceLoader.java index c8561dc..c9b65d7 100644 --- a/dice-lang/src/bjc/dicelang/util/ResourceLoader.java +++ b/dice-lang/src/bjc/dicelang/util/ResourceLoader.java @@ -1,42 +1,41 @@ -package bjc.dicelang.util;
-
-import bjc.dicelang.Errors;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static bjc.dicelang.Errors.ErrorKey.EK_MISC_IOEX;
-
-/**
- * Load resources bundled with DiceLang
- *
- * @author EVE
- *
- */
-public class ResourceLoader {
- /**
- * Loads a .help file from the data/help directory.
- *
- * @param name
- * The name of the help file to load.
- *
- * @return The contents of the help file, or null if it could not be
- * opened
- */
- public static String[] loadHelpFile(String name) {
- URL fle = ResourceLoader.class.getResource("/data/help/" + name + ".help");
-
- try {
- return Files.lines(Paths.get(fle.toURI())).toArray(sze -> new String[sze]);
- } catch(IOException ioex) {
- Errors.inst.printError(EK_MISC_IOEX, fle.toString());
- } catch(URISyntaxException usex) {
- Errors.inst.printError(EK_MISC_IOEX, fle.toString());
- }
-
- return null;
- }
-}
+package bjc.dicelang.util; + +import bjc.dicelang.Errors; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static bjc.dicelang.Errors.ErrorKey.EK_MISC_IOEX; + +/** + * Load resources bundled with DiceLang. + * + * @author EVE + * + */ +public class ResourceLoader { + /** + * Loads a .help file from the data/help directory. + * + * @param name + * The name of the help file to load. + * + * @return The contents of the help file, or null if it could not be + * opened. + */ + @SuppressWarnings("unused") + public static String[] loadHelpFile(String name) { + URL fle = ResourceLoader.class.getResource("/data/help/" + name + ".help"); + + try { + return Files.lines(Paths.get(fle.toURI())).toArray(sze -> new String[sze]); + } catch(IOException | URISyntaxException ioex) { + Errors.inst.printError(EK_MISC_IOEX, fle.toString()); + } + + return null; + } +} |
