package com.neopets.auth;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesNeopetsCredentials implements NeopetsCredentials {

  private String username;
  private String password;

  public PropertiesNeopetsCredentials(File file) throws IOException, IllegalArgumentException {
    if (!file.exists()) {
      throw new FileNotFoundException("File doesn't exist, " + file.getAbsolutePath() + ".");
    }

    FileInputStream stream = new FileInputStream(file);
    try {
      Properties properties = new Properties();
      properties.load(stream);

      username = properties.getProperty("username");
      password = properties.getProperty("password");

      if (username == null || password == null) {
        throw new IllegalArgumentException("The file, " + file.getAbsolutePath()
                + ", doesn't contain the expected properties 'username' and 'password'.");
      }
    }
    finally {
      try {
        stream.close();
      }
      catch (IOException ignored) {
      }
    }

  }

  @Override
  public String getUsername() {
    return username;
  }

  @Override
  public String getPassword() {
    return password;
  }
}

@@ -131,32 +131,60 @@
 io.IOException;%0A
+import java.io.InputStream;%0A
 import java.util
@@ -558,33 +558,24 @@
     
-FileInputStream stream = 
+readCredentials(
 new 
@@ -599,209 +599,348 @@
 ile)
-;
+);%0A
 %0A    
-try %7B%0A      Properties properties = new Properties();%0A      properties.load(stream);%0A%0A      username = properties.getProperty(%22username%22);%0A      password = properties.getProperty(%22password%22
+if (username == null %7C%7C password == null) %7B%0A      throw new IllegalArgumentException(%22The file, %22 + file.getAbsolutePath() +%0A              %22, doesn't contain the expected properties 'username' and 'password'.%22);%0A    %7D%0A  %7D%0A%0A  public PropertiesNeopetsCredentials(InputStream stream) throws IOException %7B%0A    readCredentials(stream
 );%0A%0A
-  
     
@@ -985,26 +985,24 @@
 ll) %7B%0A      
-  
 throw new Il
@@ -1033,61 +1033,32 @@
 The 
-file, %22 + file.getAbsolutePath()%0A                + %22,
+inputted properties data
  doe
@@ -1066,32 +1066,51 @@
 n't contain the 
+%22 +%0A              %22
 expected propert
@@ -1143,27 +1143,189 @@
 rd'.%22);%0A    
+%7D%0A
   %7D
+%0A%0A  private void readCredentials(InputStream stream) throws IOException %7B%0A    Properties properties = new Properties();%0A    try %7B%0A      properties.load(stream);
 %0A    %7D%0A    f
@@ -1428,16 +1428,118 @@
 %0A    %7D%0A%0A
+    username = properties.getProperty(%22username%22);%0A    password = properties.getProperty(%22password%22);%0A
   %7D%0A%0A  @

Add input stream construction of PropertiesNeopetsCredentials