{"action":"created","comment":{"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments/75631994","id":75631994,"diff_hunk":"@@ -0,0 +1,71 @@\n+package com.clouway;\n+\n+import java.io.BufferedInputStream;\n+import java.io.ByteArrayOutputStream;\n+import java.io.File;\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.net.URL;\n+import java.net.URLConnection;\n+\n+/**\n+ * @author Vasil Mitov <v.mitov.clouway@gmail.com>\n+ */\n+public class DownloadAgent {\n+  private ProgressBar progressBar;\n+\n+  /**\n+   * Constructor\n+   * @param progressBar visual feedback for progress.\n+   */\n+  public DownloadAgent(ProgressBar progressBar) {\n+    this.progressBar = progressBar;\n+  }\n+\n+  /**\n+   * Downloads a file.\n+   * @param url for the file\n+   * @param destinationFile the place to save the file\n+   * @return the donwloaded file\n+   * @throws IOException\n+   */\n+  public File downloadFile(String url, String destinationFile) throws IOException {\n+    URL urlForFile = new URL(url);\n+    URLConnection urlConnection = new URL(url).openConnection();\n+    Integer fileSize = urlConnection.getContentLength();\n+    InputStream inputStream = new BufferedInputStream(urlForFile.openStream());\n+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();","path":"src/com/clouway/DownloadAgent.java","position":38,"original_position":38,"commit_id":"f7ff4dff02cc59cf0f7c916dfa514026fa951a07","original_commit_id":"f7ff4dff02cc59cf0f7c916dfa514026fa951a07","user":{"login":"freekman","id":8199446,"avatar_url":"https://avatars.githubusercontent.com/u/8199446?v=3","gravatar_id":"","url":"https://api.github.com/users/freekman","html_url":"https://github.com/freekman","followers_url":"https://api.github.com/users/freekman/followers","following_url":"https://api.github.com/users/freekman/following{/other_user}","gists_url":"https://api.github.com/users/freekman/gists{/gist_id}","starred_url":"https://api.github.com/users/freekman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freekman/subscriptions","organizations_url":"https://api.github.com/users/freekman/orgs","repos_url":"https://api.github.com/users/freekman/repos","events_url":"https://api.github.com/users/freekman/events{/privacy}","received_events_url":"https://api.github.com/users/freekman/received_events","type":"User","site_admin":false},"body":"why dont you open a FileOutputStream instead an write directly in it and remove the ```writeFileTo````","created_at":"2016-08-22T07:59:11Z","updated_at":"2016-08-22T07:59:11Z","html_url":"https://github.com/clouway-incubator/networking-and-gui/pull/7#discussion_r75631994","pull_request_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments/75631994"},"html":{"href":"https://github.com/clouway-incubator/networking-and-gui/pull/7#discussion_r75631994"},"pull_request":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7","id":81812045,"html_url":"https://github.com/clouway-incubator/networking-and-gui/pull/7","diff_url":"https://github.com/clouway-incubator/networking-and-gui/pull/7.diff","patch_url":"https://github.com/clouway-incubator/networking-and-gui/pull/7.patch","issue_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/7","number":7,"state":"open","locked":false,"title":"Task1 ready for review","user":{"login":"VasilMitovClouway","id":18255988,"avatar_url":"https://avatars.githubusercontent.com/u/18255988?v=3","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"body":"DownloadAgent downloading files.","created_at":"2016-08-18T13:05:29Z","updated_at":"2016-08-22T07:59:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c06e1d9ed9e770f64ff10b93b44bc9bb9c74db0e","assignee":{"login":"freekman","id":8199446,"avatar_url":"https://avatars.githubusercontent.com/u/8199446?v=3","gravatar_id":"","url":"https://api.github.com/users/freekman","html_url":"https://github.com/freekman","followers_url":"https://api.github.com/users/freekman/followers","following_url":"https://api.github.com/users/freekman/following{/other_user}","gists_url":"https://api.github.com/users/freekman/gists{/gist_id}","starred_url":"https://api.github.com/users/freekman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freekman/subscriptions","organizations_url":"https://api.github.com/users/freekman/orgs","repos_url":"https://api.github.com/users/freekman/repos","events_url":"https://api.github.com/users/freekman/events{/privacy}","received_events_url":"https://api.github.com/users/freekman/received_events","type":"User","site_admin":false},"assignees":[{"login":"freekman","id":8199446,"avatar_url":"https://avatars.githubusercontent.com/u/8199446?v=3","gravatar_id":"","url":"https://api.github.com/users/freekman","html_url":"https://github.com/freekman","followers_url":"https://api.github.com/users/freekman/followers","following_url":"https://api.github.com/users/freekman/following{/other_user}","gists_url":"https://api.github.com/users/freekman/gists{/gist_id}","starred_url":"https://api.github.com/users/freekman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freekman/subscriptions","organizations_url":"https://api.github.com/users/freekman/orgs","repos_url":"https://api.github.com/users/freekman/repos","events_url":"https://api.github.com/users/freekman/events{/privacy}","received_events_url":"https://api.github.com/users/freekman/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7/commits","review_comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7/comments","review_comment_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/7/comments","statuses_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/f7ff4dff02cc59cf0f7c916dfa514026fa951a07","head":{"label":"VasilMitovClouway:task1","ref":"task1","sha":"f7ff4dff02cc59cf0f7c916dfa514026fa951a07","user":{"login":"VasilMitovClouway","id":18255988,"avatar_url":"https://avatars.githubusercontent.com/u/18255988?v=3","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"repo":{"id":64193941,"name":"networking-and-gui","full_name":"VasilMitovClouway/networking-and-gui","owner":{"login":"VasilMitovClouway","id":18255988,"avatar_url":"https://avatars.githubusercontent.com/u/18255988?v=3","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VasilMitovClouway/networking-and-gui","description":"Networking and GUI","fork":true,"url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui","forks_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/forks","keys_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/teams","hooks_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/hooks","issue_events_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/issues/events{/number}","events_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/events","assignees_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/assignees{/user}","branches_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/branches{/branch}","tags_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/tags","blobs_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/languages","stargazers_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/stargazers","contributors_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/contributors","subscribers_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/subscribers","subscription_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/subscription","commits_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/contents/{+path}","compare_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/merges","archive_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/downloads","issues_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/issues{/number}","pulls_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/labels{/name}","releases_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/releases{/id}","deployments_url":"https://api.github.com/repos/VasilMitovClouway/networking-and-gui/deployments","created_at":"2016-07-26T05:55:43Z","updated_at":"2016-04-13T13:30:12Z","pushed_at":"2016-08-18T13:20:58Z","git_url":"git://github.com/VasilMitovClouway/networking-and-gui.git","ssh_url":"git@github.com:VasilMitovClouway/networking-and-gui.git","clone_url":"https://github.com/VasilMitovClouway/networking-and-gui.git","svn_url":"https://github.com/VasilMitovClouway/networking-and-gui","homepage":null,"size":269,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"clouway-incubator:vasil_mitov","ref":"vasil_mitov","sha":"454c679487a7fb87b699bd01b979f5e926c90e88","user":{"login":"clouway-incubator","id":10173098,"avatar_url":"https://avatars.githubusercontent.com/u/10173098?v=3","gravatar_id":"","url":"https://api.github.com/users/clouway-incubator","html_url":"https://github.com/clouway-incubator","followers_url":"https://api.github.com/users/clouway-incubator/followers","following_url":"https://api.github.com/users/clouway-incubator/following{/other_user}","gists_url":"https://api.github.com/users/clouway-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway-incubator/subscriptions","organizations_url":"https://api.github.com/users/clouway-incubator/orgs","repos_url":"https://api.github.com/users/clouway-incubator/repos","events_url":"https://api.github.com/users/clouway-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/clouway-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":56154308,"name":"networking-and-gui","full_name":"clouway-incubator/networking-and-gui","owner":{"login":"clouway-incubator","id":10173098,"avatar_url":"https://avatars.githubusercontent.com/u/10173098?v=3","gravatar_id":"","url":"https://api.github.com/users/clouway-incubator","html_url":"https://github.com/clouway-incubator","followers_url":"https://api.github.com/users/clouway-incubator/followers","following_url":"https://api.github.com/users/clouway-incubator/following{/other_user}","gists_url":"https://api.github.com/users/clouway-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway-incubator/subscriptions","organizations_url":"https://api.github.com/users/clouway-incubator/orgs","repos_url":"https://api.github.com/users/clouway-incubator/repos","events_url":"https://api.github.com/users/clouway-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/clouway-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clouway-incubator/networking-and-gui","description":"Networking and GUI","fork":false,"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui","forks_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/forks","keys_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/teams","hooks_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/hooks","issue_events_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/events{/number}","events_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/events","assignees_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/assignees{/user}","branches_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/branches{/branch}","tags_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/tags","blobs_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/languages","stargazers_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/stargazers","contributors_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/contributors","subscribers_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/subscribers","subscription_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/subscription","commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/contents/{+path}","compare_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/merges","archive_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/downloads","issues_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues{/number}","pulls_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/labels{/name}","releases_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/releases{/id}","deployments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/deployments","created_at":"2016-04-13T13:30:12Z","updated_at":"2016-04-13T13:30:12Z","pushed_at":"2016-08-18T13:22:53Z","git_url":"git://github.com/clouway-incubator/networking-and-gui.git","ssh_url":"git@github.com:clouway-incubator/networking-and-gui.git","clone_url":"https://github.com/clouway-incubator/networking-and-gui.git","svn_url":"https://github.com/clouway-incubator/networking-and-gui","homepage":null,"size":150,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":3,"forks":4,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7"},"html":{"href":"https://github.com/clouway-incubator/networking-and-gui/pull/7"},"issue":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/7"},"comments":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/f7ff4dff02cc59cf0f7c916dfa514026fa951a07"}}}}
{"actor":{"display_login":"freekman"}}