CRLF example with Shift_jis
Marshaller marshaller = JAXBContext
        .newInstance(records.getClass())
        .createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "Shift_jis");
Writer writer = new StringWriter();
marshaller.marshal(records, writer);
String writeContent = writer.toString().replaceAll("\n", "\r\n");
        Recommended Posts