I need to escape the following sequence defined as a static final
final String POSIX_SIGNATURE = "ustar".concat("\0").concat("00");
How would I escape this without using the .concat()
method nor the +
string operator?
final String POSIX_SIGNATURE = "ustar\000";
This is not valid, not the same as the first one.
final String POSIX_SIGNATURE = "ustar\0\00";
Nor is this one either.
String
concatenation of literals is done during compilation, so there is really no reason you can't use something like("ustar" + "\0" + "00")
if you think it's more clear than the solutions without concatenation. See e.g. ideone.com/tkZneB. – Ellanellard