I did not try *HWPFDocument*
but given code examples on the google site should work as it. Unfortunately
following code print some boxes and rough characters. Please suggest as its
blocking for us:
for (DocumentListEntry entry : resultFeed.getEntries()) {
String docId = entry.getDocId();
String docType = entry.getType();
URL exportUrl =
new URL("https://docs.google.com/feeds/download/" + docType
+ "s/Export?docID=" + docId + "&exportFormat=doc");
MediaContent mc = new MediaContent();
mc.setUri(exportUrl.toString());
MediaSource ms = client.getMedia(mc);
InputStream inStream = null;
try {
inStream = ms.getInputStream();
int c;
while ((c = inStream.read()) != -1) {
System.out.print((char)c);
}
} finally {
if (inStream != null) {
inStream.close();
}
}
}
Thankx and Regards
Vik
Founder
http://www.sakshum.org
http://blog.sakshum.org
On Fri, Nov 18, 2011 at 7:59 PM, Amit Pandey <[email protected]> wrote:
> I did it before and I used *HWPFDocument. *However it can be read
> directly (without third party lib).
>
> Try other ways to read the string from inputStream (other than CharStreams
> api). Also try setting different possible character encoding.
>
> Let us know if this work.
>
> Thanks,
> Amit
>
> On Fri, Nov 18, 2011 at 8:46 AM, Vik <[email protected]> wrote:
>
>> hi
>>
>> plz update on this?
>>
>> Thankx and Regards
>>
>> Vik
>> Founder
>> http://www.sakshum.org
>> http://blog.sakshum.org
>>
>>
>> On Wed, Nov 16, 2011 at 7:03 PM, Vik <[email protected]> wrote:
>>
>>> No I did not used that. Do i need that one? I thought no. Please
>>> confirm.
>>>
>>> And it is strange if google api gives me access to get handle to the doc
>>> but need third party libraries to read it,
>>>
>>>
>>> Thankx and Regards
>>>
>>> Vik
>>> Founder
>>> http://www.sakshum.org
>>> http://blog.sakshum.org
>>>
>>>
>>> On Mon, Nov 14, 2011 at 1:10 PM, Amit Pandey <[email protected]>wrote:
>>>
>>>> Have you used *org.apache.poi.hwpf.HWPFDocument* API ?
>>>>
>>>> Thanks,
>>>> Amit
>>>>
>>>> On Sat, Nov 12, 2011 at 7:04 PM, Vik <[email protected]> wrote:
>>>>
>>>>> Hie Amit
>>>>>
>>>>> Thanks however when i read the input stream using:
>>>>> String content = CharStreams.toString(new InputStreamReader(inStream));
>>>>>
>>>>> It prints all boxed characters rather plain english text. Please advise
>>>>>
>>>>> Thankx and Regards
>>>>>
>>>>> Vik
>>>>> Founder
>>>>> http://www.sakshum.org
>>>>> http://blog.sakshum.org
>>>>>
>>>>>
>>>>> On Fri, Nov 11, 2011 at 5:46 PM, Amit Pandey <[email protected]>wrote:
>>>>>
>>>>>> Mistakenly send wrong code. Here is correct code.
>>>>>>
>>>>>> On Fri, Nov 11, 2011 at 5:35 PM, Amit Pandey <[email protected]>wrote:
>>>>>>
>>>>>>> Hi ViK,
>>>>>>>
>>>>>>> I did the same before and I use *org.apache.poi.hwpf.HWPFDocument*API.
>>>>>>> Following code snippet may be useful for you. Let me know if this
>>>>>>> works.
>>>>>>>
>>>>>>> for (DocumentListEntry entry : resultFeed.getEntries()) {
>>>>>>>
>>>>>>> String docId = entry.getDocId();
>>>>>>> String docType = entry.getType();
>>>>>>> URL exportUrl =
>>>>>>> new URL("https://docs.google.com/feeds/download/" +
>>>>>>> docType
>>>>>>> + "s/Export?docID=" + docId + "&exportFormat=doc");
>>>>>>> MediaContent mc = new MediaContent();
>>>>>>> mc.setUri(exportUrl.toString());
>>>>>>> MediaSource ms = client.getMedia(mc);
>>>>>>> InputStream inStream = ms.getInputStream();
>>>>>>> // Now read the content from input stream.
>>>>>>> break;
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Amit
>>>>>>>
>>>>>>> On Thu, Nov 10, 2011 at 4:09 PM, Vik <[email protected]> wrote:
>>>>>>>
>>>>>>>> Hie
>>>>>>>>
>>>>>>>> Thanks I went through it and could at least get the handle to the
>>>>>>>> google text doc i needed. I am now stuck at how to read the contents.
>>>>>>>> My code looks like:
>>>>>>>>
>>>>>>>>
>>>>>>>> GoogleOAuthParameters oauthParameters = new
>>>>>>>> GoogleOAuthParameters();
>>>>>>>> oauthParameters.setOAuthConsumerKey(Constants.CONSUMER_KEY);
>>>>>>>> oauthParameters.setOAuthConsumerSecret(Constants.CONSUMER_SECRET);
>>>>>>>>
>>>>>>>> oauthParameters.setOAuthToken(Constants.ACCESS_TOKEN);
>>>>>>>> oauthParameters.setOAuthTokenSecret(Constants.ACCESS_TOKEN_SECRET);
>>>>>>>>
>>>>>>>> DocsService client = new DocsService("sakshum-YourAppName-v1");
>>>>>>>> client.setOAuthCredentials(oauthParameters, new
>>>>>>>> OAuthHmacSha1Signer());
>>>>>>>> URL feedUrl = new URL("
>>>>>>>> https://docs.google.com/feeds/default/private/full/");
>>>>>>>> DocumentQuery dquery = new DocumentQuery(feedUrl);
>>>>>>>> dquery.setTitleQuery("blood_donor_verification_template_dev");
>>>>>>>> dquery.setTitleExact(true);
>>>>>>>> dquery.setMaxResults(10);
>>>>>>>> DocumentListFeed resultFeed = client.getFeed(dquery,
>>>>>>>> DocumentListFeed.class);
>>>>>>>> System.out.println("feed size:" + resultFeed.getEntries().size());
>>>>>>>> String emailBody = "";
>>>>>>>> for (DocumentListEntry entry : resultFeed.getEntries()) {
>>>>>>>> System.out.println(entry.getPlainTextContent());
>>>>>>>> emailBody = entry.getPlainTextContent();
>>>>>>>> }
>>>>>>>>
>>>>>>>> Plz note that entry.getPlainTextContent() does not work and throws
>>>>>>>> object not TextContent type exception
>>>>>>>>
>>>>>>>> Thankx and Regards
>>>>>>>>
>>>>>>>> Vik
>>>>>>>> Founder
>>>>>>>> http://www.sakshum.org
>>>>>>>> http://blog.sakshum.org
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Nov 6, 2011 at 10:24 PM, Vik <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> Thanks for replying
>>>>>>>>>
>>>>>>>>> actually i just googled and could not really find matching to my
>>>>>>>>> needs. thanks for the pointer this should be helpful.
>>>>>>>>>
>>>>>>>>> Thankx and Regards
>>>>>>>>>
>>>>>>>>> Vik
>>>>>>>>> Founder
>>>>>>>>> http://www.sakshum.org
>>>>>>>>> http://blog.sakshum.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Nov 4, 2011 at 12:01 AM, Ikai Lan (Google) <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Have you read this? What are your thoughts? What have you tried?
>>>>>>>>>>
>>>>>>>>>> http://code.google.com/apis/documents/
>>>>>>>>>>
>>>>>>>>>> Vik, your posts would be a lot more useful if you:
>>>>>>>>>>
>>>>>>>>>> 1. List what you have tried
>>>>>>>>>> 2. Describe what didn't work
>>>>>>>>>> 3. Describe what it is you are trying to do
>>>>>>>>>>
>>>>>>>>>> I like the fact that you keep emails short, but I suspect other
>>>>>>>>>> people on this list have tuned you out because you're just not
>>>>>>>>>> providing
>>>>>>>>>> enough information when you ask for help and it's too much detective
>>>>>>>>>> work
>>>>>>>>>> for people who would actually help out otherwise.
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Ikai Lan
>>>>>>>>>> Developer Programs Engineer, Google App Engine
>>>>>>>>>> plus.ikailan.com | twitter.com/ikai
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, Nov 3, 2011 at 10:42 AM, Vik <[email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> someone please help on this.
>>>>>>>>>>>
>>>>>>>>>>> Thankx and Regards
>>>>>>>>>>>
>>>>>>>>>>> Vik
>>>>>>>>>>> Founder
>>>>>>>>>>> http://www.sakshum.org
>>>>>>>>>>> http://blog.sakshum.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Oct 31, 2011 at 7:11 PM, Vik <[email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hie
>>>>>>>>>>>>
>>>>>>>>>>>> Can someone please guide on how to read a google doc from my
>>>>>>>>>>>> gae code?
>>>>>>>>>>>>
>>>>>>>>>>>> Thankx and Regards
>>>>>>>>>>>>
>>>>>>>>>>>> Vik
>>>>>>>>>>>> Founder
>>>>>>>>>>>> http://www.sakshum.org
>>>>>>>>>>>> http://blog.sakshum.org
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>> Google Groups "Google App Engine for Java" group.
>>>>>>>>>>> To post to this group, send email to
>>>>>>>>>>> [email protected].
>>>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>>>> [email protected].
>>>>>>>>>>> For more options, visit this group at
>>>>>>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>> Google Groups "Google App Engine for Java" group.
>>>>>>>>>> To post to this group, send email to
>>>>>>>>>> [email protected].
>>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>>> [email protected].
>>>>>>>>>> For more options, visit this group at
>>>>>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Google App Engine for Java" group.
>>>>>>>> To post to this group, send email to
>>>>>>>> [email protected].
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> [email protected].
>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Google App Engine for Java" group.
>>>>>> To post to this group, send email to
>>>>>> [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected].
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Google App Engine for Java" group.
>>>>> To post to this group, send email to
>>>>> [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Google App Engine for Java" group.
>>>> To post to this group, send email to
>>>> [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.