Пример #1
0
 public URL getURL() {
   try {
     return new URL(elt.getAttribute("url"));
   } catch (MalformedURLException e) {
     e.printStackTrace();
   }
   return null;
 }
Пример #2
0
  /**
   * opens existing file
   *
   * @param a_file
   */
  public GlyphFile(File a_file) {
    super();

    m_fileName = a_file;

    URL url = null;

    try {
      url = a_file.toURI().toURL();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }

    init(url);
  }
 /**
  * Discover WS device on the local network with specified filter
  *
  * @param regexpProtocol url protocol matching regexp like "^http$", might be empty ""
  * @param regexpPath url path matching regexp like "onvif", might be empty ""
  * @return list of unique device urls filtered
  */
 public static Collection<URL> discoverWsDevicesAsUrls(String regexpProtocol, String regexpPath) {
   final Collection<URL> urls =
       new TreeSet<>(
           new Comparator<URL>() {
             public int compare(URL o1, URL o2) {
               return o1.toString().compareTo(o2.toString());
             }
           });
   for (String key : discoverWsDevices()) {
     try {
       final URL url = new URL(key);
       boolean ok = true;
       if (regexpProtocol.length() > 0 && !url.getProtocol().matches(regexpProtocol)) ok = false;
       if (regexpPath.length() > 0 && !url.getPath().matches(regexpPath)) ok = false;
       if (ok) urls.add(url);
     } catch (MalformedURLException e) {
       e.printStackTrace();
     }
   }
   return urls;
 }