[Webfunds-commits] java/webfunds/comms URLSupport.java
Ian Grigg
iang@cypherpunks.ai
Sun, 8 Apr 2001 15:15:30 -0400 (AST)
iang 01/04/08 15:15:30
Added: webfunds/comms URLSupport.java
Log:
static methods for converting URLs
Revision Changes Path
1.1 java/webfunds/comms/URLSupport.java
Index: URLSupport.java
===================================================================
/*
* Copyright (c) 2001 Systemics Inc on behalf of
* the WebFunds Development Team. All Rights Reserved.
*/
package webfunds.comms;
import java.util.Vector;
import java.io.PrintWriter;
import java.net.URL;
import java.net.MalformedURLException;
/**
* Do some basic URL things.
*
* @version $Id: URLSupport.java,v 1.1 2001/04/08 19:15:30 iang Exp $
*/
public class URLSupport
{
private URLSupport() {}
/**
* Convert a list of strings to URLs.
* Ignores malformed ones.
* Always returns an array.
*/
public static URL[] convertToURLs(String[] stringURLs, PrintWriter bug)
{
Vector v = new Vector();
for (int i = 0; i < stringURLs.length; i++)
{
URL url;
try {
url = new URL(stringURLs[i]);
} catch (MalformedURLException ex) {
if (bug != null)
bug.println(i + ": " + ex + ":\n<<" + stringURLs[i] + ">>");
continue ;
}
v.addElement(url);
if (bug != null)
bug.println("ok " + stringURLs[i]);
}
URL[] urls = new URL[v.size()];
v.copyInto(urls);
return urls;
}
}