I wrote a java program to create a binary file compatible with PostgreSQL Copy command by using help from the following StackOverflow post:
Java library to write binary format for Postgres COPY?
I have a Postgres table column character varying(1) which can be null. Basically, this is 1 character field which can be null. so, how can I convert null into a binary string? I used the following way to convert but null is 4-character long. It is working fine with CSV file format but it's not working with a BINARY file format. Any idea will be appreciated.
String nullStr = "null";
strBytes = nullStr.getBytes("UTF-8");
nullis not the same as"null", i.e. the second one is an actual string.