views:

168

answers:

2

Hi,

I'm using the java library to access the gdata api. I just want to be able to print the contents of a document. I setup my project to list all the docs in my feed, now that I have a document listing, I want to print its contents:

for (DocumentListEntry entry : feed.getEntries()) {
    // Ok, how do we print the doc's contents now?
    entry.getContents();
}

It looks like we're supposed to get the URL from the entry, then read the contents at the URL ourselves. I found a post stating that this is how we get that URL:

MediaContent content = (MediaContent)entry.getContent(); 
String url = content.getUri();

but when I try to read from it, I get an html response saying 'this content has moved'. I read that this is because we have to authenticate our http-read method, but I'm not sure how to do that. Is there really no built-in way to do this?

Thanks

A: 

Nevermind, use this, it's wrapped up in these classes for you, thankfully:

http://code.google.com/p/gdata-java-client/source/browse/#svn/trunk/java/sample/docs

A: 
MediaContent content = (MediaContent) entry.getContent();
MediaSource source = docService.getMedia(content);
InputStream in = source.getInputStream();
jolestar