Read a file character by character/UTF8: Difference between revisions
Read a file character by character/UTF8 (view source)
Revision as of 10:19, 12 May 2023
, 1 year ago→{{header|Java}}
Line 371:
=={{header|Java}}==
<syntaxhighlight
import static java.nio.charset.StandardCharsets.UTF_8;▼
import java.io.FileReader;
import java.io.IOException;
public final class ReadFileByCharacter {
public static void main(String[] aArgs) {
String path = "C:/Users/psnow/Desktop/testFile.txt";
while ( ( value = fileReader.read() ) != END_OF_STREAM ) {
System.out.println((char) value);
}
ioe.printStackTrace();
}
}
private static final int END_OF_STREAM = -1;
▲ int value;
▲ } catch (IOException exception) {
▲ reader = new FileReader(path, UTF_8);
}
</syntaxhighlight>
{{ out }}
<pre>
R
o
s
e
t
t
a
</pre>
=={{header|jq}}==
|