Mercurial > hg > truffle
annotate mxtool/URLConnectionDownload.java @ 17345:3152f72f5cda
mx: follow redirects in URLConnectionDownload util
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Mon, 06 Oct 2014 12:02:30 +0200 |
parents | 2022366b513c |
children | 07462ba5a12a |
rev | line source |
---|---|
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 import java.io.*; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 import java.net.*; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import java.util.regex.*; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 /** |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 * Downloads content from a given URL to a given file. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 * |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 * @param path where to write the content |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 * @param urls the URLs to try, stopping after the first successful one |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 */ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 public class URLConnectionDownload { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 /** |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 * Downloads content from a given URL to a given file. |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 * |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 * @param args |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 * arg[0] is the path where to write the content. The remainder |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 * of args are the URLs to try, stopping after the first |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 * successful one |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 */ |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 public static void main(String[] args) { |
15922
2022366b513c
mx: add verbose mode to download helper
Bernhard Urban <bernhard.urban@jku.at>
parents:
5023
diff
changeset
|
45 File path = new File(args[0]); |
2022366b513c
mx: add verbose mode to download helper
Bernhard Urban <bernhard.urban@jku.at>
parents:
5023
diff
changeset
|
46 boolean verbose = args[1].equals("-v"); |
2022366b513c
mx: add verbose mode to download helper
Bernhard Urban <bernhard.urban@jku.at>
parents:
5023
diff
changeset
|
47 int offset = verbose ? 2 : 1; |
2022366b513c
mx: add verbose mode to download helper
Bernhard Urban <bernhard.urban@jku.at>
parents:
5023
diff
changeset
|
48 String[] urls = new String[args.length - offset]; |
2022366b513c
mx: add verbose mode to download helper
Bernhard Urban <bernhard.urban@jku.at>
parents:
5023
diff
changeset
|
49 System.arraycopy(args, offset, urls, 0, urls.length); |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 File parent = path.getParentFile(); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 makeDirectory(parent); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 // Enable use of system proxies |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 System.setProperty("java.net.useSystemProxies", "true"); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 String proxy = System.getenv("HTTP_PROXY"); |
5017
0b781cdb0cfb
Use lower case http_proxy because this is the default environment variable on Linux
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4188
diff
changeset
|
58 if (proxy == null) { |
5023
db072eec897e
fix variable redefinition in URLConnectionDownload
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5017
diff
changeset
|
59 proxy = System.getenv("http_proxy"); |
5017
0b781cdb0cfb
Use lower case http_proxy because this is the default environment variable on Linux
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4188
diff
changeset
|
60 } |
0b781cdb0cfb
Use lower case http_proxy because this is the default environment variable on Linux
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4188
diff
changeset
|
61 |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 String proxyMsg = ""; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 if (proxy != null) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 Pattern p = Pattern.compile("(?:http://)?([^:]+)(:\\d+)?"); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 Matcher m = p.matcher(proxy); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 if (m.matches()) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 String host = m.group(1); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 String port = m.group(2); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 System.setProperty("http.proxyHost", host); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 if (port != null) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 port = port.substring(1); // strip ':' |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 System.setProperty("http.proxyPort", port); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 proxyMsg = " via proxy " + proxy; |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 } else { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 System.err.println("Value of HTTP_PROXY is not valid: " + proxy); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 } else { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 System.err.println("** If behind a firewall without direct internet access, use the HTTP_PROXY environment variable (e.g. 'env HTTP_PROXY=proxy.company.com:80 max ...') or download manually with a web browser."); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 for (String s : urls) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 try { |
17345
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
84 while (true) { |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
85 System.err.println("Downloading " + s + " to " + path + proxyMsg); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
86 URL url = new URL(s); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
87 URLConnection conn = url.openConnection(); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
88 // 10 second timeout to establish connection |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
89 conn.setConnectTimeout(10000); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
90 |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
91 if (conn instanceof HttpURLConnection) { |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
92 // HttpURLConnection per default follows redirections, |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
93 // but not if it changes the protocol (e.g. http -> |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
94 // https). While this is a sane default, in our |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
95 // situation it's okay to follow a protocol transition. |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
96 HttpURLConnection httpconn = (HttpURLConnection) conn; |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
97 switch (httpconn.getResponseCode()) { |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
98 case HttpURLConnection.HTTP_MOVED_PERM: |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
99 case HttpURLConnection.HTTP_MOVED_TEMP: |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
100 System.err.println("follow redirect..."); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
101 s = httpconn.getHeaderField("Location"); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
102 continue; |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
103 } |
15922
2022366b513c
mx: add verbose mode to download helper
Bernhard Urban <bernhard.urban@jku.at>
parents:
5023
diff
changeset
|
104 } |
17345
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
105 InputStream in = conn.getInputStream(); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
106 int size = conn.getContentLength(); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
107 FileOutputStream out = new FileOutputStream(path); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
108 int read = 0; |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
109 byte[] buf = new byte[8192]; |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
110 int n = 0; |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
111 while ((read = in.read(buf)) != -1) { |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
112 n += read; |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
113 if (verbose) { |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
114 long percent = ((long) n * 100 / size); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
115 System.err.print("\r " + n + " bytes " + (size == -1 ? "" : " (" + percent + "%)")); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
116 } |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
117 out.write(buf, 0, read); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
118 } |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
119 System.err.println(); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
120 out.close(); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
121 in.close(); |
3152f72f5cda
mx: follow redirects in URLConnectionDownload util
Bernhard Urban <bernhard.urban@jku.at>
parents:
15922
diff
changeset
|
122 return; |
3723
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 } catch (MalformedURLException e) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 throw new Error("Error in URL " + s, e); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 } catch (IOException e) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 System.err.println("Error reading from " + s + ": " + e); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 path.delete(); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 throw new Error("Could not download content to " + path + " from " + Arrays.toString(urls)); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 private static void makeDirectory(File directory) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 if (!directory.exists() && !directory.mkdirs()) { |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 throw new Error("Could not make directory " + directory); |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 } |
6c5f528c7aac
Added a copy of the mxtool to repo.
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 |