how I can read each line of the console
The Scanner class has easy to use methods for reading from the console.if they range between the letter A-Z then store in an array..
Are you talking about single characters: A or b or K
or about Strings of characters: ADBEDE
For single characters you could use an if condition
For Strings a regular expression could test if the String contains only those letters.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
Do you have further questions about the problem?
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
What do you mean by "find the letters in the console."
Are you trying to get characters that have been written to a console?
What program is writing to the console?
I thought you meant you wanted to read data in from the console as a user entered it.
how to proceed with using String blink
For debugging: Print the String: blink to see what it contains.
When you know its contents you should be able to write code to extract the parts that you want.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
String blink = new String(chunk);
System.out.print(blink
);
Doesn't that mean that you have every line of console output in the String blinbk before it's written to the console?
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
is there a way of extracting the Strings [A-Z] from String blink before doing the System.out.print(blink)
Can you give an example of the contents of the String blink (a small one will do)
and show what you want to extract from it?
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
unfortunately yes, but is there a way of extracting the Strings [A-Z] from String blink before doing the System.out.print(blink).... Ive been testing several ideas but all have fall thru;..
Not unfortunate at all! That means you can take a copy of blink just before writing it to the console and you can do all the analysis and processing you want on it.
Now is a good time to look at the API doc for the String class where you will find loads of methods, some of which are just what you need - in particular you can check if the String is exactly one character long.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Yes, you said that already. Please re-read my previous post - it gives you info to start solving this yourself.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
How do you find the Strings that you want to extract?
Are they the lines with a single character?
The Scanner class has a constructor that you can pass a String to.
Then use the next method to "read" the tokens one by one looking for those with a length of one.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
Where does your code test the length of the String looking for a length of 1?
What does the printed output that you posted show?
For testing, use a small input with only a few lines in it so you can easily see what is happening.
Print out the value of blink before trying to scan/parse it to see what the input looks like.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
For testing, use a small input with only a few lines in it so you can easily see what is happening.
Print out the value of blink before trying to scan/parse it to see what the input looks like.
What was the input for what you just posted? It looks like the first letter of each line, not the contents of a line with only one character on it.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656