Java 7일차 URL 테스트

import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.Vector;

public class URLTest
{
public static void main(String[] args)
{
String str = "http://jiniusman.blogspot.kr/";
Vector<String> vs = new Vector<>();

try
{
URL url = new URL(str);
InputStream is = url.openStream();

Scanner sc = new Scanner(is);

while(sc.hasNext())
{
String line = sc.nextLine().trim();
if(line.substring(0, 3).equals("<ti"))
{
vs.add(line);
}
else if(line.substring(0, 3).equals("<de"))
{
vs.add(line);
}
}
}
catch(Exception e)
{
}

for(int i=0; i<vs.size(); i++)
System.out.println(vs.get(i));
}
}

댓글 없음: