src/main/java/net/systran/platform/translation/client/ApiClient.java
/**
   * Helper method to get the api key from a file location
   */
Helper method to get the api key from a file location
Helper method to get the api key from a file location
public static String LoadAPIKey(String filename) throws IOException {
    String apiKey;
    if (null == filename || 0 == filename.length())
      throw new IllegalArgumentException("Empty API key file specified.");
    File file = new File(filename);
    FileInputStream fis = new FileInputStream(file);
    BufferedReader breader = new BufferedReader(new InputStreamReader(fis));
    apiKey = breader.readLine().replaceAll("\\n", "").replaceAll("\\r", "");
    fis.close();
    breader.close();
    if (null == apiKey || apiKey.length() < 10)
      throw new IllegalArgumentException("Too short API key.");
    return apiKey;
  }
public static String LoadAPIKey ( String filename ) throws IOException { String apiKey ; if ( null == filename || 0 == filename . length ( ) ) throw new IllegalArgumentException ( "Empty API key file specified." ) ; File file = new File ( filename ) ; FileInputStream fis = new FileInputStream ( file ) ; BufferedReader breader = new BufferedReader ( new InputStreamReader ( fis ) ) ; apiKey = breader . readLine ( ) . replaceAll ( "\\n" , "" ) . replaceAll ( "\\r" , "" ) ; fis . close ( ) ; breader . close ( ) ; if ( null == apiKey || apiKey . length ( ) < 10 ) throw new IllegalArgumentException ( "Too short API key." ) ; return apiKey ; }
Helper method to get the api key from a file location
Helper method to get the api key from a file location