-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlotCAS.java
More file actions
60 lines (56 loc) · 1.96 KB
/
Copy pathPlotCAS.java
File metadata and controls
60 lines (56 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package plotCAS;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import javax.swing.JOptionPane;
public class PlotCAS {
//public Window fen;
public static String currentversion="0.2.029";
public static int nwindow=0;
public static void main(String[] args) {
/* Self-update if necessary */
URL version;
try {
version = new URL("https://raw.githubusercontent.com/MGDelcey/PlotCAS/master/version");
HttpURLConnection huc = (HttpURLConnection) version.openConnection();
huc.setConnectTimeout(1000);
huc.setReadTimeout(1000);
//huc.setRequestMethod("GET");
// try {
BufferedReader versionfile = new BufferedReader(new InputStreamReader(version.openStream()));
String versionid;
versionid = versionfile.readLine();
if (!versionid.equals(currentversion))
{
JOptionPane.showMessageDialog(null, "A new version of PlotCAS is available. The program will exit and update itself.");
try {
URL website = new URL("https://raw.githubusercontent.com/MGDelcey/PlotCAS/master/PlotCAS.jar");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(System.getProperty("user.dir")+"/PlotCAS.jar");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
System.exit(0);
} catch (IOException e) {
e.printStackTrace();
}
/* }
} catch (IOException e) {
e.printStackTrace();*/
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
/* Go */
new Window();
}
}