Cant get a direct download Link from a File Host
I want to download a File from a File Host like Workupload or Google Drive, but as far as i know the url must be a direct link to the file like this: https://some.url/files/file.txt
But File Hosts only provide Links for Web Browsers: https://workupload.com/file/someFile
I already tried to use the firefox dev tools to get direct link but that link also doesnt work, it only directs to a sub domain f59.workupload.com
My Code:
if (!dataFile.exists()) {
try {
fetchWebsite = new URL("URL");
} catch (MalformedURLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
readableByteChannel = Channels.newChannel(fetchWebsite.openStream());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try (FileOutputStream fos = new FileOutputStream(dataFile)) {
fos.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}