Code Snippet :
public static void writeStringAsCSV(String resultsetContentds,String filePath){
FileOutputStream fileoutputStream = null;
File fileInstance;
try {
fileInstance = new File(filePath);
fileoutputStream = new FileOutputStream(fileInstance);
if (!fileInstance.exists()) {
fileInstance.createNewFile();
}
byte[] contentInBytes = resultsetContentds.getBytes();
fileoutputStream.write(contentInBytes);
fileoutputStream.flush();
fileoutputStream.close();
}
catch (IOException
exceptionTrace) {
exceptionTrace.printStackTrace();
}
finally {
try {
if (fileoutputStream != null) {
fileoutputStream.close();
}
} catch (IOException exceptionTrace) {
exceptionTrace.printStackTrace();
}
}
}
No comments:
Post a Comment