@@ -12,10 +12,7 @@ public static void main(String[] args) {
1212 Matcher m = pat .matcher (inf );
1313 m .find ();
1414 String dlurl = m .group (1 );
15- main .saveUrl ("mcmu.jar" , dlurl );
16- File file = new File ("mcmu.jar" );
17- URL url = file .toURI ().toURL ();
18- URL [] urls = new URL []{url };
15+ URL [] urls = new URL []{new URL (dlurl )};
1916 URLClassLoader cl = new URLClassLoader (urls );
2017 Class cls = cl .loadClass ("mcmu.MCMU" );
2118 cls .newInstance ();
@@ -32,44 +29,9 @@ public static String getURL(String getURL) throws Exception {
3229 BufferedReader rd = new BufferedReader (new InputStreamReader (conn .getInputStream ()));
3330 String line ;
3431 while ((line = rd .readLine ()) != null ) {
35- result .append (line + "\n " );
32+ result .append (line + "\n " );
3633 }
3734 rd .close ();
3835 return result .toString ();
3936 }
40- public static String getVer () throws Exception {
41- StringBuilder result = new StringBuilder ();
42- URL url = new URL ("https://raw.githubusercontent.com/TeamEndAllReality/MCMU/master/ver" );
43- HttpURLConnection conn = (HttpURLConnection ) url .openConnection ();
44- conn .setRequestMethod ("GET" );
45- BufferedReader rd = new BufferedReader (new InputStreamReader (conn .getInputStream ()));
46- String line ;
47- while ((line = rd .readLine ()) != null ) {
48- result .append (line );
49- }
50- rd .close ();
51- return result .toString ();
52- }
53-
54- public static void saveUrl (String filename , String urlString ) throws IOException {
55- BufferedInputStream in = null ;
56- FileOutputStream fout = null ;
57- try {
58- int count ;
59- in = new BufferedInputStream (new URL (urlString ).openStream ());
60- fout = new FileOutputStream (filename );
61- byte [] data = new byte [1024 ];
62- while ((count = in .read (data , 0 , 1024 )) != -1 ) {
63- fout .write (data , 0 , count );
64- }
65- }
66- finally {
67- if (in != null ) {
68- in .close ();
69- }
70- if (fout != null ) {
71- fout .close ();
72- }
73- }
74- }
7537}
0 commit comments