// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
/**
* This method writes input stream to output file
*
* @param fileName
* name of the output file
* @param inputStream
* input stream to be written in output file
* @param fileExtension
* extension of output file
*/
public static void SaveAsFile(String fileName, InputStream inputStream, String fileExtension) {
try {
// Create stream for output file
OutputStream outputStream = new FileOutputStream(
outputPath + GetFileNameWithoutExtension(fileName) + fileExtension);
int read = 0;
byte[] bytes = new byte[1024];
// Write bytes into output stream
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
outputStream.close();
outputStream.flush();
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
}