<p>In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java String. How do I do these conversions?</p>

```
```
String original = "hello world";
byte[] utf8Bytes = original.getBytes("UTF-8");
```
```