In my code (HttpServlet in doGet method) I need to write bytes that can take any value, from 0 to 255, in a .js file. I checked in the debugger that result[1] has the value 0. However, in the external file it is written as blank space and when I try to read it has the byte value "32". I only have this problem with the byte 0, for the rest this is working perfectly. Any ideas?

```
res.setContentType("image/gif");
res.setHeader("Content-Disposition","attachment;filename=myFile.js");
OutputStream os = res.getOutputStream();
byte[] result=encrypt(req.getParameter("original")); // Here result has values [64,0,81,80]
os.write(result,0,result.length);

```

I retrieve the values from an external JavaScript:

```
var whatever = data[1].charCodeAt(0); // whatever has value 32

```

I have seen a similar problem in a Javascript program, and they fixed this problem including this loop right before writing to file:

```
for (var i=0; i<result.length; i++) {
    result[i] = String.fromCharCode(result[i]); }

```

I have do some tests and works for Javascript. What would be the equivalent in Java?

Thanks