function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Puspender TanwarPuspender Tanwar 

Format of csv provided by salesforce when using bulk api

Hello,
I am using the salesforce bulk api to extract data. I have some issue with the format that salesforce provide me the data using Bulk api. Below is the short code i used which ran successfully and creates a csv for me :
InputStream inputStream = bulkConnection.getQueryResultStream(job.getId(), batchInfo.getId(), resultId);
OutputStream out = new FileOutputStream(file);

try {
	int read = 0;
	byte[] bytes = new byte[1024];
		 
	while ((read = inputStream.read(bytes)) != -1) {
			out.write(bytes, 0, read);
	}
	inputStream.close();
	out.flush(); 
	logger.log(logger.DEBUG,"New file created!");
	} catch (IOException e) {
		logger.log(logger.DEBUG,"ErrorMsg in wrtting csv file"+e.getMessage());
		throw new RuntimeException("ErrorMsg in wrtting csv file"+e.getMessage());
}

All I have done is wrote the bytes provided by salesforce into a csv file, i have not changed/modified anything. Now the issue is, in this csv all the Logical records are terminated by LF(Line feed) and the physical records are terminated by CRLF(carriage return + Line feed). attached is the snapshot
csv by bulk api
Now  if I download the same objects records by using Data Loader, the downloaded csv is of different format. In this csv all logical records are terminated by CRLF and physical by LF, opposite of bulk api csv.
csv by Data Loader

All I want to known is if there is any way I can download the records in the format that Data Loader provide, by using the bulk api.
Any suggestion would  be heartily appreciated. Thanks