Convert URL to URI using lambdaj

import ch.lambdaj.function.convert.Converter;
 
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
 
public class ConvertUrlToUri implements Converter<URL, URI>
{
   public static ConvertUrlToUri convertUrlToUri()
   {
      return new ConvertUrlToUri();
   }
 
   @Override
   public URI convert(final URL from)
   {
      try
      {
         return from.toURI();
      }
      catch (final URISyntaxException e)
      {
         throw new RuntimeException("unable to convert " + from + " to URI", e);
      }
   }
}

Leave a Reply

Your email address will not be published. Required fields are marked *