Answer the question
In order to leave comments, you need to log in
How to convert character code to character in java?
There is the following code
package test;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class Main {
static FileInputStream in = null;
static BufferedInputStream bin = null;
public static void main(String[] args) throws IOException {
try {
in = new FileInputStream(new File("res/text.txt"));
bin = new BufferedInputStream(in);
boolean eof = false;
while (!eof) {
int byteValue = bin.read();
System.out.println((char) byteValue +"");
if (byteValue == -1) {
eof = true;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
in.close();
bin.close();
}
}
}
Answer the question
In order to leave comments, you need to log in
package test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static BufferedReader bf;
public static void main(String[] args) throws IOException {
try {
bf = new BufferedReader (
new InputStreamReader(
new FileInputStream( "res/text.txt" ), "UTF-8"
)
);
String line = "";
while (line != null) {
line = bf.readLine();
System.out.println(line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
bf.close();
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question