Java 如何找到离家近的maven存储库

Java 如何找到离家近的maven存储库,java,maven-2,maven,Java,Maven 2,Maven,我想知道如何找到我家附近的maven存储库?有官方的中央存储库镜像列表(作为xml文件)和另一个中央存储库镜像列表。实际上,在的列表是有问题的。在旧金山,加利福尼亚还是密苏里的圣路易斯?(我想这是一个不经意的教训,说明了为什么不应该对代码甚至xml进行注释)。为了让事情更加混乱,域名的所有者(根据)在马里兰州富尔顿 也许问题不是“仓库在哪里?”(以撒回答了这个问题),而是: “如何找到离我家最近的maven存储库?” 这个问题也困扰着我 另一方面,考虑到数据包在世界各地的传播速度,这真的很重要吗

我想知道如何找到我家附近的maven存储库?

有官方的中央存储库镜像列表(作为xml文件)和另一个中央存储库镜像列表。

实际上,在的列表是有问题的。在旧金山,加利福尼亚还是密苏里的圣路易斯?(我想这是一个不经意的教训,说明了为什么不应该对代码甚至xml进行注释)。为了让事情更加混乱,域名的所有者(根据)在马里兰州富尔顿

也许问题不是“仓库在哪里?”(以撒回答了这个问题),而是: “如何找到离我家最近的maven存储库?”

这个问题也困扰着我

另一方面,考虑到数据包在世界各地的传播速度,这真的很重要吗

但它仍然困扰着我

有两种方法可以找出最接近的主机:

  • 打开浏览器,转到,然后键入主机名。如果你知道自己在哪里,那么你可以去谷歌地图,了解方向,并查看距离

  • 打开终端窗口,ping主机名以查找平均往返传输时间(毫秒)。这将为您提供电子距离,这对于文件传输时间来说更为重要

  • 对每个主机名重复此操作(例如,如果您正在查看Maven本身的下载站点,则大约重复40次)

  • 根据谷歌地图上的距离、方向或通过时间进行排序

  • 对于40台主机,您可能可以在20分钟内手动完成这项工作,但真正的专业人士更愿意花几个小时编写Selenium和java代码,以便在5分钟内完成这项工作

    在我丰富的业余时间里,我只做了一半的工作(即没有硒):

    我的Utils类包括以下内容:

    /**
     * Given a string of words separated by spaces, returns the first word.
     * @param string
     * @return
     */
    public static String first(String string) {
        if (isNullOrEmptyString(string)) { return ""; }
        string = string.trim();
        int index = string.indexOf(" ");  //TODO: shouldn't this be "\\s+" to handle double spaces and tabs? That means regexp version of indexOf
        if (index<0) { return string; }
        return string.substring(0, index);
    }
    
    /**
     * Given a string of words separated by spaces, returns the rest of the string after the first word.
     * @param string
     * @return
     */
    public static String rest(String string) {
        if (isNullOrEmptyString(string)) { return ""; }
        string = string.trim();
        int index = string.indexOf(" ");  //TODO: shouldn't this be "\\s+" to handle double spaces and tabs? That means regexp version of indexOf
        if (index<0) { return ""; }
        return  string.substring(index+1);
    } 
    
    public static String grep(String regexp, String multiLineStringToSearch) {
        String result = "";
        //System.out.println("grep for '"+ regexp + "'");
        String[] lines = multiLineStringToSearch.split("\\n");
        //System.out.println("grep input string contains "+ lines.length + " lines.");
        Pattern pattern = Pattern.compile(regexp);
        for (String line : lines) {
            Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
                //System.out.println("grep found match="+ line);
                result = result + "\n" + line;
            }
        }
        return result.trim();
    }
    
    /**
     * Given the path and name of a plain text (ascii) file,
     * reads it and returns the contents as a string.
     * @param filePath
     * @return
     */
    public static String readTextFile(String filePath) {   
        BufferedReader reader;
        String result = "";
        int counter = 0;
        try {
            reader = new BufferedReader(new FileReader(filePath));
            String line = "";
            StringBuilder  stringBuilder = new StringBuilder();
            String lineSeparator = System.getProperty("line.separator");
            while ((line = reader.readLine()) != null) {
                counter = counter + 1;
                stringBuilder.append(line);
                stringBuilder.append(lineSeparator);
            }
            reader.close();
            result = stringBuilder.toString();
            logger.info("readTextFile: Read "+filePath+" with "+ counter + " lines, "+result.length()+" characters.");
            return result;
        } catch (FileNotFoundException e) {
            logger.fatal("readTextFile: Could not find file "+filePath+".");
            e.printStackTrace();
        } catch (IOException e) {
            logger.fatal("readTextFile: Could not read file "+filePath+".");
            e.printStackTrace();
        }
        return "";
    }
    
    public static boolean isNullOrEmptyString(String s) {
        return (s==null || s.equals(""));
    }
    
    /**
     * Given a string of words separated by one or more whitespaces, returns the Nth word.
     * @param string
     * @return
     */
    public static String nth(String string, int n) {
        string = string.trim();
        String[] splitstring = string.split("\\s+");
        String result = "";
        if (splitstring.length<n) { return ""; }
        else {
            result = splitstring[n - 1];
        }
        return result.trim();
    }
    
    /**
     * Given a string of words separated by spaces, returns the last word.
     * @param string
     * @return
     */
    public static String last(String string) {
        return  string.substring(string.trim().lastIndexOf(" ")+1, string.trim().length());
    }
    
    /**
    *给定由空格分隔的字符串,返回第一个单词。
    *@param字符串
    *@返回
    */
    公共静态字符串优先(字符串){
    if(isNullOrEmptyString(string)){return”“;}
    string=string.trim();
    int index=string.indexOf(“”;//TODO:这不应该是“\\s+”来处理双空格和制表符吗?这意味着indexOf的regexp版本
    如果(索引)
    
    apache.claz.org
    apache.cs.utah.edu
    apache.mesi.com.ar
    apache.mirrors.hoobly.com
    apache.mirrors.lucidnetworks.net
    apache.mirrors.pair.com
    apache.mirrors.tds.net
    apache.osuosl.org
    apache.petsads.us
    apache.spinellicreations.com
    apache.tradebit.com
    download.nextag.com
    ftp.osuosl.org
    ftp://mirror.reverse.net/pub/apache/ 
    mirror.cc.columbia.edu/pub/software/apache/
    mirror.cogentco.com/pub/apache/
    mirror.metrocast.net/apache/
    mirror.nexcess.net/apache/
    mirror.olnevhost.net/pub/apache/
    mirror.reverse.net/pub/apache/
    mirror.sdunix.com/apache/
    mirror.symnds.com/software/Apache/
    mirror.tcpdiag.net/apache/
    mirrors.gigenet.com/apache/
    mirrors.ibiblio.org/apache/
    mirrors.sonic.net/apache/
    psg.mtu.edu/pub/apache/
    supergsego.com/apache/
    www.bizdirusa.com
    www.bizdirusa.com/mirrors/apache/
    www.carfab.com/apachesoftware/
    www.dsgnwrld.com/am/
    www.eng.lsu.edu/mirrors/apache/
    www.gtlib.gatech.edu/pub/apache/
    www.interior-dsgn.com/apache/
    www.motorlogy.com/apache/
    www.picotopia.org/apache/
    www.poolsaboveground.com/apache/
    www.trieuvan.com/apache/
    www.webhostingjams.com/mirror/apache/
    
    /**
     * Given a string of words separated by spaces, returns the first word.
     * @param string
     * @return
     */
    public static String first(String string) {
        if (isNullOrEmptyString(string)) { return ""; }
        string = string.trim();
        int index = string.indexOf(" ");  //TODO: shouldn't this be "\\s+" to handle double spaces and tabs? That means regexp version of indexOf
        if (index<0) { return string; }
        return string.substring(0, index);
    }
    
    /**
     * Given a string of words separated by spaces, returns the rest of the string after the first word.
     * @param string
     * @return
     */
    public static String rest(String string) {
        if (isNullOrEmptyString(string)) { return ""; }
        string = string.trim();
        int index = string.indexOf(" ");  //TODO: shouldn't this be "\\s+" to handle double spaces and tabs? That means regexp version of indexOf
        if (index<0) { return ""; }
        return  string.substring(index+1);
    } 
    
    public static String grep(String regexp, String multiLineStringToSearch) {
        String result = "";
        //System.out.println("grep for '"+ regexp + "'");
        String[] lines = multiLineStringToSearch.split("\\n");
        //System.out.println("grep input string contains "+ lines.length + " lines.");
        Pattern pattern = Pattern.compile(regexp);
        for (String line : lines) {
            Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
                //System.out.println("grep found match="+ line);
                result = result + "\n" + line;
            }
        }
        return result.trim();
    }
    
    /**
     * Given the path and name of a plain text (ascii) file,
     * reads it and returns the contents as a string.
     * @param filePath
     * @return
     */
    public static String readTextFile(String filePath) {   
        BufferedReader reader;
        String result = "";
        int counter = 0;
        try {
            reader = new BufferedReader(new FileReader(filePath));
            String line = "";
            StringBuilder  stringBuilder = new StringBuilder();
            String lineSeparator = System.getProperty("line.separator");
            while ((line = reader.readLine()) != null) {
                counter = counter + 1;
                stringBuilder.append(line);
                stringBuilder.append(lineSeparator);
            }
            reader.close();
            result = stringBuilder.toString();
            logger.info("readTextFile: Read "+filePath+" with "+ counter + " lines, "+result.length()+" characters.");
            return result;
        } catch (FileNotFoundException e) {
            logger.fatal("readTextFile: Could not find file "+filePath+".");
            e.printStackTrace();
        } catch (IOException e) {
            logger.fatal("readTextFile: Could not read file "+filePath+".");
            e.printStackTrace();
        }
        return "";
    }
    
    public static boolean isNullOrEmptyString(String s) {
        return (s==null || s.equals(""));
    }
    
    /**
     * Given a string of words separated by one or more whitespaces, returns the Nth word.
     * @param string
     * @return
     */
    public static String nth(String string, int n) {
        string = string.trim();
        String[] splitstring = string.split("\\s+");
        String result = "";
        if (splitstring.length<n) { return ""; }
        else {
            result = splitstring[n - 1];
        }
        return result.trim();
    }
    
    /**
     * Given a string of words separated by spaces, returns the last word.
     * @param string
     * @return
     */
    public static String last(String string) {
        return  string.substring(string.trim().lastIndexOf(" ")+1, string.trim().length());
    }