Home » Android » android – Read text file from google drive-Exceptionshub

android – Read text file from google drive-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment


I have simple text file in my google drive and it is publicly shared. When I read it

   InputStream is = new URL(url).openStream();

The following is read. I assume my file is google doc format. Is there anyway I can read it as a text or convert it to text?

   <!DOCTYPE html><html><head><meta name="google" content="notranslate"><meta http-equiv="X-UA-  
   Compatible" content="IE=edge;"><meta name="viewport" content="width=device-width, initial-
   scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/><style>@font-face{font-       
How to&Answers:

I would recommend you to use the Drive API, using the Files: export endpoint and setting the mimeType as text/plain, you will be able to get the file as the format you want.

You can check the Java Quickstart to get an idea about how to use the API on Java.