{"action":"created","comment":{"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments/42212067","id":42212067,"diff_hunk":"@@ -0,0 +1,53 @@\n+package com.clouway.downloadagent;\n+\n+import java.io.*;\n+import java.net.MalformedURLException;\n+import java.net.URL;\n+import java.nio.Buffer;\n+import java.nio.file.*;\n+\n+/**\n+ * @author Slavi Dichkov (slavidichkof@gmail.com)\n+ */\n+public class DownloadAgent {\n+    public int downloаdFile(String URL, String target) {\n+        InputStream inputStream = null;\n+        OutputStream outputStream = null;\n+        java.net.URL url = null;\n+        int counter = 0;\n+        try {\n+            url = new URL(URL);\n+            Path path = Paths.get(URL).getFileName();\n+            Path projectDirectory = Paths.get(target);\n+            String fileName = projectDirectory.getParent() + \"/\" + String.valueOf(path.toString());\n+            inputStream = new BufferedInputStream(url.openStream());\n+            outputStream = new BufferedOutputStream(new FileOutputStream(fileName));\n+            double length = inputStream.available();\n+            double hundredth = length / 100;\n+            double temp = hundredth;\n+            int readByte;\n+            int percent = 0;\n+            while ((readByte = inputStream.read()) != -1) {\n+                outputStream.write(readByte);\n+                counter++;\n+                if (counter >= temp) {\n+                    temp += hundredth;\n+                    percent++;\n+                    progress(percent);\n+                }\n+                outputStream.flush();\n+            }\n+            inputStream.close();\n+            outputStream.close();\n+        } catch (MalformedURLException e) {\n+            return 0;\n+        } catch (IOException e) {\n+            return 0;\n+        }\n+        return counter;\n+    }\n+\n+    public void progress(int progressPercent){\n+        System.out.println(progressPercent+\"%\");","path":"src/com/clouway/downloadagent/DownloadAgent.java","position":null,"original_position":51,"commit_id":"65d66b1371688038aaa88b32a248bbe9af4b930d","original_commit_id":"07fd3678943e5bcb9c5e0aa212d669832b93553d","user":{"login":"slavidichkov","id":12229758,"avatar_url":"https://avatars.githubusercontent.com/u/12229758?v=3","gravatar_id":"","url":"https://api.github.com/users/slavidichkov","html_url":"https://github.com/slavidichkov","followers_url":"https://api.github.com/users/slavidichkov/followers","following_url":"https://api.github.com/users/slavidichkov/following{/other_user}","gists_url":"https://api.github.com/users/slavidichkov/gists{/gist_id}","starred_url":"https://api.github.com/users/slavidichkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavidichkov/subscriptions","organizations_url":"https://api.github.com/users/slavidichkov/orgs","repos_url":"https://api.github.com/users/slavidichkov/repos","events_url":"https://api.github.com/users/slavidichkov/events{/privacy}","received_events_url":"https://api.github.com/users/slavidichkov/received_events","type":"User","site_admin":false},"body":"done\r\n","created_at":"2015-10-16T06:25:11Z","updated_at":"2015-10-16T06:25:11Z","html_url":"https://github.com/clouway-incubator/networking-and-gui/pull/1#discussion_r42212067","pull_request_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments/42212067"},"html":{"href":"https://github.com/clouway-incubator/networking-and-gui/pull/1#discussion_r42212067"},"pull_request":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1","id":47752011,"html_url":"https://github.com/clouway-incubator/networking-and-gui/pull/1","diff_url":"https://github.com/clouway-incubator/networking-and-gui/pull/1.diff","patch_url":"https://github.com/clouway-incubator/networking-and-gui/pull/1.patch","issue_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/1","number":1,"state":"open","locked":false,"title":"Networking: downloadagent","user":{"login":"slavidichkov","id":12229758,"avatar_url":"https://avatars.githubusercontent.com/u/12229758?v=3","gravatar_id":"","url":"https://api.github.com/users/slavidichkov","html_url":"https://github.com/slavidichkov","followers_url":"https://api.github.com/users/slavidichkov/followers","following_url":"https://api.github.com/users/slavidichkov/following{/other_user}","gists_url":"https://api.github.com/users/slavidichkov/gists{/gist_id}","starred_url":"https://api.github.com/users/slavidichkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavidichkov/subscriptions","organizations_url":"https://api.github.com/users/slavidichkov/orgs","repos_url":"https://api.github.com/users/slavidichkov/repos","events_url":"https://api.github.com/users/slavidichkov/events{/privacy}","received_events_url":"https://api.github.com/users/slavidichkov/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-15T07:22:26Z","updated_at":"2015-10-16T06:25:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c20affb13d5b4aaba2a4c082e4def7c191652b1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1/commits","review_comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1/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/1/comments","statuses_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/65d66b1371688038aaa88b32a248bbe9af4b930d","head":{"label":"slavidichkov:downloadagent","ref":"downloadagent","sha":"65d66b1371688038aaa88b32a248bbe9af4b930d","user":{"login":"slavidichkov","id":12229758,"avatar_url":"https://avatars.githubusercontent.com/u/12229758?v=3","gravatar_id":"","url":"https://api.github.com/users/slavidichkov","html_url":"https://github.com/slavidichkov","followers_url":"https://api.github.com/users/slavidichkov/followers","following_url":"https://api.github.com/users/slavidichkov/following{/other_user}","gists_url":"https://api.github.com/users/slavidichkov/gists{/gist_id}","starred_url":"https://api.github.com/users/slavidichkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavidichkov/subscriptions","organizations_url":"https://api.github.com/users/slavidichkov/orgs","repos_url":"https://api.github.com/users/slavidichkov/repos","events_url":"https://api.github.com/users/slavidichkov/events{/privacy}","received_events_url":"https://api.github.com/users/slavidichkov/received_events","type":"User","site_admin":false},"repo":{"id":44242829,"name":"networking-and-gui","full_name":"slavidichkov/networking-and-gui","owner":{"login":"slavidichkov","id":12229758,"avatar_url":"https://avatars.githubusercontent.com/u/12229758?v=3","gravatar_id":"","url":"https://api.github.com/users/slavidichkov","html_url":"https://github.com/slavidichkov","followers_url":"https://api.github.com/users/slavidichkov/followers","following_url":"https://api.github.com/users/slavidichkov/following{/other_user}","gists_url":"https://api.github.com/users/slavidichkov/gists{/gist_id}","starred_url":"https://api.github.com/users/slavidichkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavidichkov/subscriptions","organizations_url":"https://api.github.com/users/slavidichkov/orgs","repos_url":"https://api.github.com/users/slavidichkov/repos","events_url":"https://api.github.com/users/slavidichkov/events{/privacy}","received_events_url":"https://api.github.com/users/slavidichkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/slavidichkov/networking-and-gui","description":"Networking and GUI","fork":true,"url":"https://api.github.com/repos/slavidichkov/networking-and-gui","forks_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/forks","keys_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/teams","hooks_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/hooks","issue_events_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/issues/events{/number}","events_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/events","assignees_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/assignees{/user}","branches_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/branches{/branch}","tags_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/tags","blobs_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/languages","stargazers_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/stargazers","contributors_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/contributors","subscribers_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/subscribers","subscription_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/subscription","commits_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/contents/{+path}","compare_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/merges","archive_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/downloads","issues_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/issues{/number}","pulls_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/labels{/name}","releases_url":"https://api.github.com/repos/slavidichkov/networking-and-gui/releases{/id}","created_at":"2015-10-14T11:18:27Z","updated_at":"2015-09-24T11:23:01Z","pushed_at":"2015-10-16T06:24:27Z","git_url":"git://github.com/slavidichkov/networking-and-gui.git","ssh_url":"git@github.com:slavidichkov/networking-and-gui.git","clone_url":"https://github.com/slavidichkov/networking-and-gui.git","svn_url":"https://github.com/slavidichkov/networking-and-gui","homepage":null,"size":148,"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:slavi","ref":"slavi","sha":"6604dc3fc61595d134abd2756dc8001f59ba2f94","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":43062597,"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}","created_at":"2015-09-24T11:23:01Z","updated_at":"2015-09-24T11:23:01Z","pushed_at":"2015-10-16T06:24:28Z","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":148,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1"},"html":{"href":"https://github.com/clouway-incubator/networking-and-gui/pull/1"},"issue":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/1"},"comments":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/1/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/1/commits"},"statuses":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/65d66b1371688038aaa88b32a248bbe9af4b930d"}}}}