Reading characters from Word? Java

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?

thank

+5
source share
6 answers
String input = "apple";
char[] arr = input.toCharArray();
System.out.println(Arrays.toString(arr));

Conclusion:

[a, p, p, l, e]
+5
source

The method read() BufferedReadergives you one character.

Check it out .

+1
source

char[] read.

+1

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);
   }
+1

- char. , .split("delim"), .

+1

You can use read()in the class BufferedReaderor use the method toCharArray(). Both can be used.

String input="Apple";
BufferedReader br=BufferedReader.read(input);

or
char in=input.toCharArray();
+1
source

All Articles