2

I have a Fixed Length stream. I want to set encoding to Windows-1252 or latin1.

How can I do that?

Via XML would be better, but if code is the only way, it is ok too.

Mr Mashabela
  • 112
  • 2
  • 10
Vitaly Olegovitch
  • 3,509
  • 6
  • 33
  • 49

1 Answers1

5

Character encoding is controlled external to the BeanIO library using the basic Java I/O APIs. Here's a quick and dirty example showing the setup for writing:

Charset charset = Charset.forName("ISO-8859-1"); // ISO Latin Alphabet No. 1
OutputStream ostream = new ByteArrayOutputStream(); // or other OutputStream
Writer writer = new OutputStreamWriter(ostream, charset);

BeanWriter beanWriter = streamFactory.createWriter(nameOfMappedStream, writer);

// write beans here...

writer.flush();

Reading should be similar.

kem
  • 1,127
  • 8
  • 14