尝试在Link Checker程序中打印出链接和状态

时间:2013-04-23 12:07:04

标签: java println linkchecker

我有一个小程序可以确定给定网址中断链接的状态。当代码运行时,它首先在列表中打印链接,然后单独打印http状态。我的问题是我想打印链接旁边的打印状态,如下所示:http://stackoverflow.com状态= 200 OK。

我附上我的代码:

public class ilikecode{

public static List getLinks(String uriStrng){

        //.....

        URL url = new URI(uriStrng).toURL();
        URLConnection connection = url.openConnection();
        Reader rd = new InputStreamReader(connection.getInputStream());

        {

        SimpleAttributeSet s = (SimpleAttributeSet)it.getAttributes();

        String link = (String)s.getAttribute(HTML.Attribute.HREF);

        if(link != null && !"http".regionMatches(true, 0, link, 0, 4))
        link = uriStrng + link;

        if (link != null) 

        {

         //System.out.println("link print finished");
         result.add(link);

        }

        System.out.println(link);
        it.next();

        }

        }

        catch (IOException e){

        } 

        catch (URISyntaxException e) 

        {

        } 

        catch (BadLocationException e) 

        {

        }

        return result;

        }

public static void LinkSorter(List<String> list)

        {

        int count = 0;

        for(int i=0; i<list.size();i++)

        {


        if(CheckInputII((String) list.get(i)) != null)

        {

        count++;

        }

        }

        System.out.println("We have found " + count + " broken links");

        }

}

0 个答案:

没有答案