🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #20593

Re: �����Ķ���swt-designer��רҵ������?

#20593
From: ˯����
Date: Tue, 16 Dec 2003 06:29
106 lines
4446 bytes
����У�⣬������һ����д�Ĺ��߰ɣ��Լ����Կ���
���һ�£�һ�㲻�ü�Сʱ�Ϳ����ҵ��ˡ�
��Ϊ����·�����dz�����Ч�ģ��Ժ����°汾Ҳ�����Լ���ȥ��
����������µ�1.2.2Pro�ģ�ϣ��Դ���а���


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Random;

public class URLClient {
    protected URLConnection connection;
    private static int MAX_VALUE = 0xFFFFF;

    public static void main(String[] args) {
        URLClient client = new URLClient();
        String urlStr;
        int count = 0;
        do {
            urlStr = nextUrl();
            count++;
            System.out.print(count + "# Trying... ");
        } while (!isDowndloadable(urlStr));
        if (count > MAX_VALUE) {
            System.out.println("Not found :( ");
        } else {
            System.out.println("Bingle!!!\nThe Url is: " + urlStr);
        }
    }

    private static String nextUrl(int iBefore) {
        int iNum = iBefore++;
        String temp = Integer.toHexString(iNum);
        if(temp.length()<5){
            String blankStr = "";
            for(int i=0;i<(5-temp.length());i++){
                blankStr +="0";
            }
            temp = blankStr + temp;
        }
        
        String urlStr =
            "http://www.instantiations.com/download/rad"
                + temp
                + ".tmp/swt_designer_pro_v1.2.2_for_Eclipse3.0.zip";
        return urlStr;
    }

    private static String nextUrl() {
        int iNum = (new Random().nextInt(0xFFFFF));
        String temp = Integer.toHexString(iNum);
        if(temp.length()<5){
            String blankStr = "";
            for(int i=0;i<(5-temp.length());i++){
                blankStr +="0";
            }
            temp = blankStr + temp;
        }
        
        String urlStr =
            "http://www.instantiations.com/download/rad"
                + temp
                + ".tmp/swt_designer_pro_v1.2.2_for_Eclipse2.1.zip";
        return urlStr;
    }

    public static boolean isDowndloadable(String urlString) {
        StringBuffer document = new StringBuffer();
        try {
            URL url = new URL(urlString); //������������
            URLConnection conn = url.openConnection();
            BufferedReader reader =
                new BufferedReader(
                    new InputStreamReader(conn.getInputStream()));

            if ((reader.readLine()) != null) {
                return true;
            }

            reader.close();
        } catch (MalformedURLException e) {
            System.out.println("Unable to connect to URL: " + urlString);
        } catch (IOException e) {
            System.out.println(
                "IOException when connecting to URL: " + urlString);
        }
        return false;
    }

}


�� �� eldon (don) �Ĵ������ᵽ: ��
: ��������������88�ѣ���
: �� �� ndugu (˯����) �Ĵ������ᵽ: ��
: : ���У��ٺ١�������ȷʵ�ܲ��?
: : �����ǵ���վֱ�����ص�pro��
: : ����Ȥ�������Կ�...


--
�� ��Դ:��Ʈ��ˮ�Ƽ� Freecity.dhs.org��[FROM: ndugu]
Technical Details
Message-ID: <49fCgT$A0G@Freecity.dhs.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer2.atl.newshosting.com!167.206.3.103.MISMATCH!news3.optonline.net!maily.cic.tsinghua.edu.cn!news.ccie.net.cn!Freecity

Show Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB
X-Google-Thread: f6cb0,4effca13dcb064bc
X-Google-Attributes: gidf6cb0,public
X-Google-ArrivalTime: 2003-12-15 22:27:09 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer2.atl.newshosting.com!167.206.3.103.MISMATCH!news3.optonline.net!maily.cic.tsinghua.edu.cn!news.ccie.net.cn!Freecity
From: ndugu.bbs@Freecity.dhs.org (˯����)
Newsgroups: cn.bbs.comp.lang.java
Subject: Re: �����Ķ���swt-designer��רҵ������?
Date: 16 Dec 2003 06:29:09 GMT
Organization: Ʈ��ˮ�Ƽ�
Message-ID: <49fCgT$A0G@Freecity.dhs.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: Java/M.1071555581.A