Exemple #1
0
  public void saveFromResponse(Connection.Response response, String filename) throws IOException {
    File folder = new File(OUTPUT_FOLDER);
    if (!folder.exists()) {
      if (!folder.mkdir()) {
        throw new IOException("Could not mkdir : " + folder);
      }
    }

    FileOutputStream out = (new FileOutputStream(new java.io.File(OUTPUT_FOLDER + filename)));
    out.write(
        response.bodyAsBytes()); // resultImageResponse.body() is where the image's contents are.
    out.close();
  }