Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.util
Class URLs

java.lang.Object
  extended by imp.util.URLs

public class URLs
extends Object

This factory contains methods to load/save URL's contents.


Method Summary
static BufferedImage loadImage(String location)
          Loads an image from the given location.
static String loadString(String location, Value query)
          Loads an URL textual contents and returns it as a string.
static void play(String location)
          Plays an audio clip (stop playing previous clip if the location is null).
static void saveImage(String location, BufferedImage image)
          Saves an image at the given location in png format.
static void saveString(String location, String string)
          Saves a char-sequence in an URL textual contents.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadImage

public static BufferedImage loadImage(String location)
                               throws IOException
Loads an image from the given location.

Parameters:
location - A Universal Resource Location of the form:
http:/path-nameto load from a HTTP location
ftp:/path-nameto load from a FTP site
file:/path-nameto load from a file
jar:/jar-path-name!/jar-entryto load from a JAR archive
Throws:
IOException - if an I/O exception has occurred.

loadString

public static String loadString(String location,
                                Value query)
                         throws IOException
Loads an URL textual contents and returns it as a string.

Parameters:
location - A Universal Resource Location of the form:
http:/path-name to load from a HTTP location
http:/path-name?param_i=value_i&.. to get a form answer
servlet:host-name:port?param_i=value_i&.. to get a query from a servlet
ftp:/path-name to load from a FTP site
file:/path-name to load from a file
jar:/jar-path-name!/jar-entry to load from a JAR archive
(e.g.:jar:http:/www-sop.inria.fr/odyssee/imp/imp.jar!/META-INF/MANIFEST.MF)
stdin: to load the whole stdin contents.
query - [optional, default is added to the host-name or null] The query fields (i.e. parameters of the form name=value). It can also be specified with the location using the <location>?<name>=<value&.. URL encoded construct or omitted.
Throws:
IOException - if an I/O exception has occurred.

play

public static void play(String location)
                 throws IOException
Plays an audio clip (stop playing previous clip if the location is null).

Parameters:
location - A Universal Resource Location of the form:
http:/path-nameto load from a HTTP location
ftp:/path-nameto load from a FTP site
file:/path-nameto load from a file
jar:/jar-path-name!/jar-entryto load from a JAR archive
Throws:
IOException - if an I/O exception has occurred.

saveImage

public static void saveImage(String location,
                             BufferedImage image)
                      throws IOException
Saves an image at the given location in png format.

Parameters:
location - A Universal Resource Location of the form:
ftp:/path-nameto save onto a FTP site.
file:/path-nameto save into a file.
image - The image to save.
Throws:
IOException - if an I/O exception has occurred.

saveString

public static void saveString(String location,
                              String string)
                       throws IOException
Saves a char-sequence in an URL textual contents.

Parameters:
location - [optional, default is "stdout:"] A Universal Resource Location of the form:
ftp:/path-nameto save onto a FTP site.
file:/path-nameto save into a file.
mailto:address?subject=subjectto send as an email in a readable form.
stdout:/to print to the terminal standard output.
string - The string to save.
Throws:
IOException - if an I/O exception has occurred.