Split a string into an array consisting of a single letters.
Is their anyway to split a string into an array where each index contains only one letter?
Ive read about the tokinizer but this splits words from what ive read. Ty for the help.
Is their anyway to split a string into an array where each index contains only one letter?
Ive read about the tokinizer but this splits words from what ive read. Ty for the help.
> Have a look at String's toCharArray() method.
and if you want a String[] array rather than a char[] array then you could useString[] asStringArray = "abcde".split("(?<=.)(?=.)");
One minor problem, this will give you an array of length 1 containing an empty string when the original is empty.
i got it, ty. I have it in another thread, trying to figure out how to use it todo what i want lol.
> i got it, ty. I have it in another thread, trying to
> figure out how to use it todo what i want lol.
Tut tut tut! Cross posting just wastes our time. Please don't do it!
Ok sry i have no clue what to name this, sry.
Heres the code.
public static void sendWord(Robot robot, String word){
String wordUp = word.toUpperCase();
char [] letters = wordUp.toCharArray();
for(int i = 0; i < letters.length; i++){
System.out.println(letters[i]);
pressKey(robot, KeyEvent.VK_letters[i]);
}
}
The problem is apperant. the wonderfull pressKey(robot, KeyEvent.VK_letters);
How should i go about doing this? This seems pretty self explanitory, but it might not be so if i need to explain the code i will.
Message was edited by:
krrose27
What don't you understand about "Please don't cross post"?
http://forum.java.sun.com/thread.jspa?threadID=5194900&tstart=0
im trying to take each latter of the word that i separate and genrate its key code. if u need me to comment each line i can.
the ommented code
public static void sendWord(Robot robot, String word){
String wordUp = word.toUpperCase();// convert the passed strin to caps.
char [] letters = wordUp.toCharArray();//split each letter in the word into its own char.
for(int i = 0; i < letters.length; i++){//a for loop
System.out.println(letters[i]);//out print the current letter
pressKey(robot, KeyEvent.VK_letters[i]);//try and generate the keycode for that letter, the thing wihch i have no clue todo.
}
}
> huh?
huh?
Edit: never mind: I'm not going to take the trouble anymore after an uninterested huh?.
Message was edited by:
prometheuzz
> Just pass the characters through then. ...VK_R
> is the same as the char R.
R dosent mean the same as vk_r their is no just r.
> R dosent mean the same as vk_r their is no just r.
System.out.println(java.awt.event.KeyEvent.VK_R == 82);
System.out.println(java.awt.event.KeyEvent.VK_R == 'R');
well if i put KeyEvent.R in eclipse it, and if i run it it says theirs and unresolved compilation problem. SO apperantly not.
> well if i put KeyEvent.R in eclipse it, and if i run
> it it says theirs and unresolved compilation problem.
> SO apperantly not.
You seem to have all the answers yourself already. Good luck.
> > well if i put KeyEvent.R in eclipse it, and if i
> run
> > it it says theirs and unresolved compilation
> problem.
> > SO apperantly not.
>
> You seem to have all the answers yourself already.
> Good luck.
im sorry i just relised i miss understood u u meant the letter without the keyevent stuff before it, thats why it wasnt workin. Sry man, i appologise.