July 2015
Beginner to intermediate
600 pages
18h 59m
English
You are going to have one class handle the networking in PhotoGallery. Create a new Java class and, since you will be connecting to Flickr, name this class FlickrFetchr.
FlickrFetchr will start off small with only two methods: getUrlBytes(String) and getUrlString(String). The getUrlBytes(String) method fetches raw data from a URL and returns it as an array of bytes. The getUrlString(String) method converts the result from getUrlBytes(String) to a String.
In FlickrFetchr.java, add implementations for getUrlBytes(String) and getUrlString(String) (Listing 23.3).
Listing 23.3 Basic networking code (FlickrFetchr.java)
public class FlickrFetchr {
public byte[] getUrlBytes(String urlSpec) throws IOException {Read now
Unlock full access