append bytes to string in java

I have to deal with ascii structured file, I need to put these two constant bytes to the end of every line so that I can respect the file structure that was gave me:

private final static int ENDRECORD = 0x0d;
private final static int ENDLINE = 0x0a;

I don't know if it's the classic "\n", is there a way I can put these two variables at the end of a string? Like:

String line = line + ENDRECORD + ENDLINE; //I now this is wrong

Jon Skeet
people
quotationmark

Just change your constants to be strings instead:

private final static String ENDRECORD = "\r";
private final static String ENDLINE = "\n";

Then your existing concatenation should be fine.

char would be fine too:

private final static char ENDRECORD = '\r'; // Or (char) 0x0d
private final static char ENDLINE = '\n';   // Or (char) 0x0a

You should think of characters as characters rather than either bytes or integer values. It'll make your text handling a lot simpler.

people

See more on this question at Stackoverflow