/**
* 웹페이지 가져오기
* URL과 저장할 파일을 입력하면
* 사이트 내용을 가지고 와서 파일에 저장함
*
*/
public class WebSpider {
public static void main(String[] args){
if(args.length != 2){
System.out.println("사용법" : java WebSpider URL filename");
System.exit(1);
}
URL url = null;
try{
url = new URL(args[0]);
}catch(MalformedURLException e1){
System.out.println("잘못된 URL 형식입니다.");
System.out.println(e1);
System.exit(1);
}
FileOutputStream fos = null;
try{
InputStream in = url.openStream();
fos = new FileOutputStream(args[1]);
byte[] buffer = new byte[512];
int readCount = 0;
System.out.println("읽어 오기 시작함 ...");
while((readCount = in.read(buffer)) != -1){
fos.write(buffer,0,readCount);
}
System.out.println(args[1] + " 파일에 모두 저장했습니다.");
}catch(Exception ex){
System.out.println(ex);
}finally{
try{
if(fos != null) fos.close();
}catch(Exception e){}
}
}
}
Java URL 사용법
git 명령어
$ git remote -v
origin git@github.daumkakao.com:dennis-lee/vertx-sample.git (fetch)
origin git@github.daumkakao.com:dennis-lee/vertx-sample.git (push)
$ git log -2
commit 69b4285dd8d1df3debdc24c24a9ee2c22c797931
Author: dennis.lee
Date: Mon May 29 18:29:43 2017 +0900
json prettify
commit de8c8a8f8a55a4b9a4a89d13cfa04e5001004c1e
Author: dennis.lee
Date: Mon May 29 18:17:22 2017 +0900
added BodyHandler
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: pom.xml
Untracked files:
(use "git add ..." to include in what will be committed)
src/main/java/net/sample/
no changes added to commit (use "git add" and/or "git commit -a")
$ git branch b1
$ git branch
b1
* master
$ git checkout -b b2
M pom.xml
Switched to a new branch 'b2'
$ git branch
b1
* b2
master
$ git branch --delete b1
Deleted branch b1 (was 69b4285).
$ git branch -d b2
Deleted branch b2 (was 69b4285).
$ git branch
* master
$ git push origin --delete b1
To github.daumkakao.com:dennis-lee/prada.git
- [deleted] b1
피드 구독하기:
글 (Atom)
깔끔 테마. Powered by Blogger.