Reputation: 109
I am having some text files in my google drive and wants to read them in my java code. The below code only reads its metadata but not the contents of file.
URL fileURL = new URL("https://doc-0c-ao-docs.googleusercontent.com/docs....");
Scanner readFile = new Scanner(fileURL.openStream());
while(readFile.hasNext())
System.out.println(readFile.nextLine());
Upvotes: 2
Views: 3974
Reputation: 221
Is the link you're using a direct (perma)link to the .txt file? Like this link: plain text file
Or does the link you're using open in google drive (browser)?
EDIT:
Like you said in your commend, the file starts downloading. So the link you're using, is in fact a download link and not a direct link to the .txt file.
You can do two things:
Get the direct link to the .txt file
Or
Use the Google Docs API.
Upvotes: 1