|
From: <bma...@us...> - 2017-01-02 14:42:30
|
Revision: 9496
http://sourceforge.net/p/fudaa/svn/9496
Author: bmarchan
Date: 2017-01-02 14:42:28 +0000 (Mon, 02 Jan 2017)
Log Message:
-----------
Ajout d'une methode pour tester qu'une URL est accessible.
Modified Paths:
--------------
trunk/framework/ctulu-fu/src/main/java/com/memoire/fu/FuLib.java
trunk/framework/fudaa-common/src/main/java/org/fudaa/fudaa/commun/impl/FudaaStartupExitPreferencesPanel.java
Modified: trunk/framework/ctulu-fu/src/main/java/com/memoire/fu/FuLib.java
===================================================================
--- trunk/framework/ctulu-fu/src/main/java/com/memoire/fu/FuLib.java 2016-12-30 14:55:02 UTC (rev 9495)
+++ trunk/framework/ctulu-fu/src/main/java/com/memoire/fu/FuLib.java 2017-01-02 14:42:28 UTC (rev 9496)
@@ -14,11 +14,25 @@
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
@@ -1907,4 +1921,23 @@
* System.exit(0); } BuPreferences.BU.put("memory",""+m); }
*/
+ /**
+ * Controls that a resource exists on WWW.
+ *
+ * @param _url The url to be found.
+ * @return True : The file exists and is accessible.
+ */
+ public static boolean existsURL(URL _url) {
+ try {
+ HttpURLConnection.setFollowRedirects(false);
+ HttpURLConnection con=(HttpURLConnection) _url.openConnection();
+ con.setRequestMethod("HEAD");
+ // note : you may also need
+ // con.setInstanceFollowRedirects(false);
+ return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
}
Modified: trunk/framework/fudaa-common/src/main/java/org/fudaa/fudaa/commun/impl/FudaaStartupExitPreferencesPanel.java
===================================================================
--- trunk/framework/fudaa-common/src/main/java/org/fudaa/fudaa/commun/impl/FudaaStartupExitPreferencesPanel.java 2016-12-30 14:55:02 UTC (rev 9495)
+++ trunk/framework/fudaa-common/src/main/java/org/fudaa/fudaa/commun/impl/FudaaStartupExitPreferencesPanel.java 2017-01-02 14:42:28 UTC (rev 9496)
@@ -25,9 +25,11 @@
*/
public class FudaaStartupExitPreferencesPanel extends BuAbstractPreferencesPanel implements ActionListener {
+ public static final String PREF_CHECK_NEW_VERSION = "check.update";
+
private final String splash_ = "splashscreen.visible";
private final String exit_ = "confirm.exit";
- private final String update_ = "check.update";
+
final BuCheckBox cbExit_;
final BuCheckBox cbSplash_;
final BuCheckBox cbUpdate_;
@@ -75,7 +77,7 @@
BuPreferences.BU.putBooleanProperty(exit_, cbExit_.isSelected());
BuPreferences.BU.putBooleanProperty(splash_, cbSplash_.isSelected());
if (cbUpdate_ != null) {
- BuPreferences.BU.putBooleanProperty(update_, cbUpdate_.isSelected());
+ BuPreferences.BU.putBooleanProperty(PREF_CHECK_NEW_VERSION, cbUpdate_.isSelected());
}
setDirty(false);
}
@@ -85,7 +87,7 @@
cbExit_.setSelected(BuPreferences.BU.getBooleanProperty(exit_, true));
cbSplash_.setSelected(BuPreferences.BU.getBooleanProperty(splash_, true));
if (cbUpdate_ != null) {
- cbUpdate_.setSelected(BuPreferences.BU.getBooleanProperty(update_, true));
+ cbUpdate_.setSelected(BuPreferences.BU.getBooleanProperty(PREF_CHECK_NEW_VERSION, true));
}
setDirty(false);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|