[JAVA] How to specify character code and line feed code in JAXB

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

How to specify character code and line feed code in JAXB
How to set character code and line feed code in Eclipse
Convert line feed code to html line feed tag with Thymeleaf and output
[swift5] How to specify color in hexadecimal
How to specify id attribute in JSF
Create your own dialect to convert line feed code to line feed tag in Thymeleaf3
How to color code console output in Eclipse
How to implement UICollectionView in Swift with code only
How to display a browser preview in VS Code
How to convert A to a and a to A using AND and OR in Java
How to specify the resource path in HTML import
How to handle TSV files and CSV files in Ruby
How to check CircleCI code and automatically deploy to Heroku
How to launch Swagger UI and Swagger Editor in Docker
[Personal application work memo] How to display a bar graph and a line graph in one graph
How to write good code
How to separate words in names in classes, methods, and variables
[Forge] How to register your own Entity and Entity Render in 1.13.2
[Rails] How to define macros in Rspec and standardize processing
What happened in "Java 8 to Java 11" and how to build an environment
How to call and use API in Java (Spring Boot)
How to select a specified date by code in FSCalendar
Correct the character code in Java and read from the URL
[Swift5] How to avoid applying dark mode (dark appearance) in code
How to develop and register a Sota app in Java
Differences in how to handle strings between Java and Perl
How to install PHP 7.4 and SQL Server drivers in CentOS 7.7
[Xcode] How to arrange Xcode and Simulator screens in full screen
How to include PKCE Code_Verifier and Code_Challenge in JMeter requests
How to dynamically switch between FIN and RST in Netty
How to apply C code format from the command line
How to write when you want to keep line breaks and output while avoiding XSS in Rails
Code to specify the image name as a character string and paste it into ImageView (android)
How to POST JSON in Java-Method using OkHttp3 and method using HttpUrlConnection-
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
How to set and use profile in annotation-based Configuration in Spring framework
How to write ruby if in one line Summary by beginner
[jOOQ] How to CASE WHEN in the WHERE / AND / OR clause
How to delete large amounts of data in Rails and concerns
How to install the language used in Ubuntu and how to build the environment
Only this! How to prevent forgetting code format in team development
[Convenient to remember !!!] How to convert from LocalDate type to character string and from character string to LocalDate type
How to get and add data from Firebase Firestore in Ruby
I tested how to use Ruby's test / unit and rock-paper-scissors code.
How to encrypt and decrypt with RSA public key in Java
How to increment the value of Map in one line in Java
How to use Lombok in Spring
How to use StringBurrer and Arrays.toString.
How to find May'n in XPath
Guess the character code in Java
How to hide scrollbars in WebView
How to specify validation for time_field
How to run JUnit in Eclipse
How to use EventBus3 and ThreadMode
How to iterate infinitely in Ruby
[Rails] How to write in Japanese
How to run Ant in Gradle
How to master programming in 3 months
How to enclose any character with "~"
How to learn JAVA in 7 days
How to get parameters in Spark