Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to read space separated characters in java

# Let input sequence is like ' A B C D E F ( 9 5 a b z '

while(Scanner.hasNextLine()){
  String[] c = fileReader.nextLine().split(" ");
  for(int i=0;i<c.length;i++){
      System.out.print("My character is " + c[i] + " "); 
      // this is enough for the input sequence
      // but if you want a safe approach then use it
      for(int j=0;j<c[i].length;j++){
          System.out.print("My character is " + c[j].charAt(j) + " ");
   	  }
}
 
PREVIOUS NEXT
Tagged: #read #space #separated #characters #java
ADD COMMENT
Topic
Name
4+4 =