diff options
author | Shevek <[email protected]> | 2015-07-28 17:27:44 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2015-07-28 17:27:44 -0700 |
commit | 7832018265ee5e369355381dcc170bdbbdfce65a (patch) | |
tree | d73554c05a0fd5a6f13b7dce9f33560f2e30800b /src/main/java/org/anarres/cpp/FileLexerSource.java | |
parent | 6b418b25fbf2b15de1df5d2b5409adf847cefde0 (diff) |
Fix some findbugs warnings.
Diffstat (limited to 'src/main/java/org/anarres/cpp/FileLexerSource.java')
-rw-r--r-- | src/main/java/org/anarres/cpp/FileLexerSource.java | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/main/java/org/anarres/cpp/FileLexerSource.java b/src/main/java/org/anarres/cpp/FileLexerSource.java index b3b3e88..7dc883a 100644 --- a/src/main/java/org/anarres/cpp/FileLexerSource.java +++ b/src/main/java/org/anarres/cpp/FileLexerSource.java @@ -18,8 +18,10 @@ package org.anarres.cpp; import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; +import java.nio.charset.Charset; import javax.annotation.Nonnull; /** @@ -29,7 +31,7 @@ import javax.annotation.Nonnull; * * @see Source */ -public class FileLexerSource extends LexerSource { +public class FileLexerSource extends InputLexerSource { private final String path; private final File file; @@ -39,29 +41,38 @@ public class FileLexerSource extends LexerSource { * * Preprocessor directives are honoured within the file. */ - public FileLexerSource(@Nonnull File file, String path) + public FileLexerSource(@Nonnull File file, @Nonnull Charset charset, @Nonnull String path) throws IOException { - super( - new BufferedReader( - new FileReader( - file - ) - ), - true - ); - + super(new FileInputStream(file), charset); this.file = file; this.path = path; } + public FileLexerSource(@Nonnull File file, @Nonnull String path) + throws IOException { + this(file, Charset.defaultCharset(), path); + } + + public FileLexerSource(@Nonnull File file, @Nonnull Charset charset) + throws IOException { + this(file, charset, file.getPath()); + } + + @Deprecated public FileLexerSource(@Nonnull File file) throws IOException { - this(file, file.getPath()); + this(file, Charset.defaultCharset()); + } + + public FileLexerSource(@Nonnull String path, @Nonnull Charset charset) + throws IOException { + this(new File(path), charset, path); } + @Deprecated public FileLexerSource(@Nonnull String path) throws IOException { - this(new File(path), path); + this(path, Charset.defaultCharset()); } @Nonnull |