save binary data in a file

I have some encrypted data as a a body in the response object and that object need to be written in a file. Any help is appreciated

Hi @rajib.podder, try searching the forum for “write to file” for example this might get you started: How to create a Katalon method (Keyword) for writing to a text file with Java

Response object have the encrypted string. I need to save the encrypted string in a file.
If response is converted to String then the file data is corrupted
String Path=“/enc.txt”;

		File targetFile = new File(Path)
		OutputStream outputStream = new FileOutputStream(targetFile)
		outputStream.write(apiResponse.getResponseBodyContent().getBytes())
		outputStream.flush()
		outputStream.close()
1 Like

Hi @rajib.podder here is a link that might get you started in the right direction: java - How to write encrypted data to a text file? - Stack Overflow

I am not an expert at writing encrypted data to a file but maybe one of the other Katalon forum members/gurus can/could suggest a possible solution.