Normally, this error occurs when Chinese appears in the Java Project code
or compile through, but when the run of Chinese garbled.
This time only need to add the following sentence in the Build.gradle can be solved
Tasks.withtype (javacompile) {
options.encoding = ' UTF-8 '
}
For example, the following code
Package com.liran.main.Stream;
Import Java.io.FileOutputStream;
Import Java.nio.file.Files;
Import java.nio.file.Paths;
Import java.util.List;
/**
* Test through the files and paths operation file
* Created by Liran on 2015-10-19.
*
/public class Newio2test {public
static void Main (string[] args) throws Exception {
System.out.println (" Ah ah ah ah ");
Copy file
files.copy (Paths.get ("Newio2test.java"), New FileOutputStream ("NewIO2Test.txt"));
List<string> Lines=files.readalllines (Paths.get ("Newio2test.java"));
SYSTEM.OUT.PRINTLN (lines);
}
There's going to be the wrong one.
This time I add that phrase and compile
Apply plugin: ' java '
dependencies {
compile filetree (dir: ' Libs ', include: [' *.jar ']
}
Tasks.withtype (javacompile) {
options.encoding = ' UTF-8 '
}
Passed the