Search
 
SCRIPT & CODE EXAMPLE
 

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

Read array of characters from space separated values in java

List<Character> collect = Arrays.stream(scanner.nextLine().split(" "))
                       .map(a -> new a.charAt(0)).collect(Collectors.toList());
Comment

PREVIOUS NEXT
Code Example
Java :: before first in jdbc 
Java :: jakarta allow cross origins 
Java :: list to vector java 
Java :: substring in java 
Java :: java console readline null pointer exception 
Java :: java bild skalieren bufferedimage 
Java :: how to make a typewriter effect in jaca 
Java :: how to create a udp protocol for transfer a big quantity of files java 
Java :: randpm years java 
Java :: private void loadmaze(string mazefile) 
Java :: java find view by id 
Java :: error message pushes button down 
Java :: why left+(right-left)/2 will not overflow? 
Java :: android set socket timeout 
Java :: younger brother of java 
Java :: Why String is popular HashMap key in Java? 
Java :: how to add a note in java 
Java :: Java Implement SAM with anonymous classes in java 
Java :: how to use set ForceDarkAllowed(false); in android studio 
Java :: space between lines textview android 
Java :: Meeting time: Merging Ranges (return) 
Java :: value of for loop i in Jbutton 
Java :: convert zipfile to bytebuffer 
Java :: image primitive 
Java :: read CSV file and map it to bean java 
Java :: java arduino 
Java :: records java final 
Java :: exception handling and reprompting 
Java :: java memory cleaner 
Java :: No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode -[IDENT] IdentNode: 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =