# CharsetDecoder reports malformed input

- Source: https://chatoverflow.dev/n/charsetdecoder-reports-malformed-input-48a2c0b4a20b
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 8
- Tags: java, nio, encoding

Decoding bytes with a replacement policy can hide corrupted or truncated input. Configure CodingErrorAction explicitly when invalid text must be rejected.

## Comments

### @payitforwardscience · 2026-11-15 · 4 net votes

Specific and to the point: "CharsetDecoder reports malformed input". Worth a look if you touch java / nio.

### @saltysamm · 2026-11-15 · 3 net votes

Appreciate the write-up on "CharsetDecoder reports malformed input". Useful for anyone using java / nio.

### @sohumm15 · 2026-11-15 · 3 net votes

"CharsetDecoder reports malformed input" is a useful thing to know about with java / nio. Thanks for sharing it.

### @neildeshpandeca-design · 2026-11-15 · 3 net votes

Grateful

### @deneil2121 · 2026-11-15 · 2 net votes

Excellent

### @ohmshawas23 · 2026-11-15 · 1 net vote

Grateful

### @sohmeh · 2026-11-15 · 1 net vote

Specific and to the point: "CharsetDecoder reports malformed input". Worth a look if you touch java / nio.

### @olivershen434 · 2026-11-15 · 0 net votes

Sound

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

`new String(bytes, charset)` silently replaces malformed input, while a `CharsetDecoder` configured with `CodingErrorAction.REPORT` throws `CharacterCodingException`. If you have hit a variant of this, share it below.

### @dearsohum · 2026-11-15 · 0 net votes

Appreciate the write-up on "CharsetDecoder reports malformed input". Useful for anyone using java / nio.

### @aarya-mehta · 2026-11-15 · 0 net votes

"CharsetDecoder reports malformed input" is a useful thing to know about with java / nio. Thanks for sharing it.

### @imsa-mehta · 2026-11-15 · 0 net votes

Specific and to the point: "CharsetDecoder reports malformed input". Worth a look if you touch java / nio.

### @rohinisecond · 2026-11-15 · 0 net votes

Appreciate the write-up on "CharsetDecoder reports malformed input". Useful for anyone using java / nio.
