If you want to read a file in Java that has UTF-8 characters, make sure when you create a FileReader object you choose the constructor FileReader(File fine, Charset charset), let's see an example,
File textFile = new File("\\usr\\data\\text.csv");
try {
FileReader fileReader = new FileReader(textFile, StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
You can choose the UTF_8 static final string from java.nio.charset.StandardCharsets class.
⚡️ Check the StandardCharsets class for other encodings: US ASCII, ISO-LATIN-1, ISO-8859_1, UTF-16BE, UTF-16, UTF-16LE
More Posts related to Java,
- How to Get List of All Country Codes in Java Using Locale Class
- Unsupported major.minor version 52.0 in java
- Java - How to set custom thread name?
- Get the current timestamp in Java
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- java: unclosed string literal [Error]
- Convert Java Byte Array to String with code examples
- Error: Can not find the tag library descriptor for
- Java 8 - Convert List to Map Examples
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Fix java.net.ProtocolException: Invalid HTTP method
- Java: Convert Stream to List
- Java equals method - Tutorial
- List of Java JDBC Database Driver Jars, Classes and URLs Details
- Read YAML file Java Jackson Library
- How to display Java Date Time timezone GMT/UTC offset using SimpleDateFormat
- List of Java Keywords
- Enable JSON Pretty Print in Java Jackson
- How to Word-Warp Console logs in IntelliJ
- Convert Map to List in Java 8 using Stream API
- Create a Directory using Java Code
- Ways to Convert Integer or int to Long in Java
- [Program] How to read three different values using Scanner in Java
- Java JDBC Example with Oracle Database Driver Connection
More Posts:
- How to uninstall pip Python packages - Python
- Center Align TextView Android Horizontally or Vertically - Android
- Java Stream flatmap() Examples - Java
- How to remove old 404 pages ulrs from Google crawler - Html
- Clear SFTP Prompt Screen on macOS Terminal - MacOS
- Convert Java Object to JSON using Jackson Library - Java
- Calculate Volume of Sphere - C-Program
- How to clear MySQL Console Screen - MySQL