2014년 1월 6일 월요일

[예제]HTTP - WebClient를 이용한 웹문서 다운로드 예제[재직자무료교육/프로그래머교육/구로디지털IT교육,오라클/자바/닷넷/C#/iOS/안드로이드/아이폰교육]

[예제]HTTP - WebClient를 이용한 웹문서 다운로드 예제[재직자무료교육/프로그래머교육/구로디지털IT교육,오라클/자바/닷넷/C#/iOS/안드로이드/아이폰교육]

//아래의 예제는 www.oraclejavanew.kr의 index.html을 클라이언트의 현재 폴더에 index.html이라는 이름으로 저장 하는 예제 입니다.

using System;
using System.Net;
using System.IO;

class OpenRead
{
        static void Main()
        {
                byte[] bytes = new byte[409600];
                WebClient client = new WebClient();
                string URL = "http://www.oraclejavanew.kr/index.html";
                Stream streamData = client.OpenRead(URL);
                StreamReader sr = new StreamReader(streamData);

                //파일을 생성 한다.
                FileInfo file = new FileInfo (@".\index.html");
                StreamWriter sw = file.CreateText();
               
                sw.Write (sr.ReadToEnd());
               
                Console.WriteLine("writing file...");               
        }
}
 


  • JAVA
  • ORACLE
  • iPhone/Android
  • .NET
  • 표준웹/HTML5
  • 채용/취업무료교육
  • 초보자(재학생)코스

  • 댓글 없음:

    댓글 쓰기