Skip to content

Commit

Permalink
Use a temporary variable for ignored lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Feb 22, 2022
1 parent c72edf7 commit 17b62b5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Expand Up @@ -50,7 +50,8 @@ private AtomicProperties() throws IOException {
String configFile = "org/openscience/cdk/config/data/whim_weights.txt";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(configFile);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ins));
if (bufferedReader.readLine() == null) // header
String header = bufferedReader.readLine();
if (header == null) // header
throw new IOException("Expected header, but reached end of input");

String Line;
Expand Down
Expand Up @@ -203,7 +203,8 @@ private RGroupQuery parseRGFile(RGroupQuery rGroupQuery) throws CDKException {

for (int i = 1; i <= 3; i++) {
lineCount++;
if (input.readLine() == null) {
line = input.readLine();
if (line == null) {
throw new CDKException("RGFile invalid, empty/null header line at #" + lineCount);
}
//optional: parse header info here (not implemented)
Expand Down
Expand Up @@ -141,7 +141,8 @@ private IChemFile readChemFile() throws CDKException {
// skip lines
logger.warn("Dropping block: ", command);
for (int i = 0; i < lineCount; i++) {
if (input.readLine() == null)
line = input.readLine();
if (line == null)
throw new CDKException("End of input while skipping lines!");
}
}
Expand Down
Expand Up @@ -113,7 +113,8 @@ public <T extends IChemObject> T read(T object) throws CDKException {
if ("CARTESIAN COORDINATES".equals(line.trim())) {

IAtomContainer atomcontainer = ((IAtomContainer) object);
if (input.readLine() == null) //reads blank line
line = input.readLine();
if (line == null) //reads blank line
throw new IllegalArgumentException("Blank line expected, but reached end of input");
line = input.readLine();

Expand Down

0 comments on commit 17b62b5

Please sign in to comment.