Basically you should specify an encoding in the Java code. Currently, your code will produce different outputs on different systems as it uses the platform-default encoding (e.g. Windows-1252 or UTF-8).
I would encourage you to use UTF-8 in both cases:
// Java 7 onwards
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
// Java pre-7
byte[] bytes = text.getBytes("UTF-8");
// .NET
byte[] bytes = Encoding.UTF8.GetBytes(text);
Using UTF-8 allows for all valid Unicode strings to be encoded into bytes. You could consider using UTF-16, but then you need to make sure you specify the same endianness in each case. That does have the benefit of having exactly two bytes per char
regardless of content though (as a char
is a UTF-16 code unit in both Java and .NET).