Not able to download file from Sharepoint Online Site Document Library
Using Below code I am able to get List of file available in that folder
jsonString = SPOnline.get(token, domain, "/sites/MySite/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/Folder/My%20Sub%20Folder/Inside%20Sub%20Folder')/Files?$expand=Files");
Now I am iterating those file list and trying to download each file using
jsonString = SPOnline.get(token, domain, url );
Saving jsonString above output to file as:
File targetFile = new File("D:\\SharePoint\\TempDownload/"+fileName);
InputStream stream = new ByteArrayInputStream( jsonString.getBytes() );
Files.copy(stream, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
I am able to save file but not able to read/open them in respective apps e.g. Excel files.
Need help..
Thanks