글쓴이 :박재형 2000년 1월 24일 11:59:00
안녕하세요
main method에서 url을 받아 인자로 channel_url_html_read(String input_Url)
메소드로 넘겨주는 데요,아래와 같은 error가 납니다. input_Url을 그냥 인터넷
주소 스트링으로 읽어서 그런것 같은 데요, 저장된 진짜 주소를 넘겨받는 방법이
없을까요? source code를 보와주시고 한번 봐 주세요.
미리 감사 ^^;
URL_Parsing.java:9: Exception java.net.MalformedURLException must be caught,
or it must be declared in the throws clause of this method.
URL channel = new URL(input_Url);
^
URL_Parsing.java:10: Exception java.io.IOException must be caught, or it
must be declared in the throws clause of this method.
BufferedReader URL_in = new BufferedReader( new
InputStreamReader(channel.openStream()));
^
2 errors
/// source code
import java.io.*;
import java.net.*;
import java.lang.System;
public class URL_Parsing {
public static void channel_url_html_read(String input_Url) {
URL channel = new URL(input_Url);
BufferedReader URL_in = new BufferedReader( new
InputStreamReader(channel.openStream()));
File outputFile = new File("Html.txt");
FileOutputStream out = new FileOutputStream(outputFile);
int c;
while((c = URL_in.read()) != -1) {
out.write(c);
}
out.close();
}
public static void main(String[] args) throws IOException {
File inputFile = new File("Channel_URL.txt");
FileInputStream in = new FileInputStream(inputFile);
BufferedReader Channel_in = new BufferedReader(new InputStreamReader(in));
String inputURL;
while((inputURL = Channel_in.readLine()) != null) {
channel_url_html_read(inputURL);
}
in.close();
}
}