CS 1705 Library

cs1705.web
Class WebUtilities

java.lang.Object
  extended by cs1705.web.WebUtilities

public class WebUtilities
extends Object

This class provides static utility methods that streamline some web-related operations.

Version:
2007.10.11
Author:
Stephen Edwards

Method Summary
static String urlEncode(String content)
          Encodes a string for use in a URL.
static URL urlFor(String url)
          Creates a URL object from a string, without throwing declared exceptions.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

urlEncode

public static String urlEncode(String content)
Encodes a string for use in a URL. This operation wraps the behavior of URLEncoder.encode(String,String), using a UTF-8 encoding and turning any exceptions into RuntimeExceptions.

Parameters:
content - The string to encode
Returns:
The URL-encoded version of the parameter

urlFor

public static URL urlFor(String url)
Creates a URL object from a string, without throwing declared exceptions. This wrapper simplifies creation of URL objects in student code by eliminating the need for explicit try/catch blocks if you just want to create a new URL object.

Parameters:
url - The url as a string
Returns:
The new URL object for the given address

Last updated: Wed, Apr 1, 2009 • 12:29 AM EDT

Copyright © 2009 Virginia Tech.