I try to get characters or letters from a word.
For instance:
input = "apple" output = "a", "p", "p", "l", "e"
However, I use a class BufferedReader. Is there a way to read characters using BufferedReader?
BufferedReader
thank
String input = "apple"; char[] arr = input.toCharArray(); System.out.println(Arrays.toString(arr));
Conclusion:
[a, p, p, l, e]
The method read() BufferedReadergives you one character.
read()
Check it out .
char[] read.
char[]
read
int read() BufferedReader, . :
BufferedReader br = ... int value=0; // reads to the end of the stream while((value = br.read()) != -1) { // converts int to character char c = (char)value; // prints character System.out.println(c); }
- char. , .split("delim"), .
.split("delim")
You can use read()in the class BufferedReaderor use the method toCharArray(). Both can be used.
toCharArray()
String input="Apple"; BufferedReader br=BufferedReader.read(input); or char in=input.toCharArray();