English 中文(简体)
• 如何将 lo子转化为 Str子或果园,以生产一系列序列到 mo曲线?
原标题:How to convert an int for loop to a String or char for loop to output a series of sequences to the mouse cursor?
  • 时间:2023-08-26 23:18:10
  •  标签:
  • java

我试图把“a”和“zzzzzz”之间的每一序列信函输出到 mo曲线。 我急于这样做,以便顺利地与 in一道工作,但 Java却不易转换到Sting或果园。

 import java.awt.AWTException;
 import java.awt.event.InputEvent;
 import java.awt.Robot;
 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.StringSelection;
 import java.awt.event.KeyEvent;
 import java.util.concurrent.TimeUnit;
 public class robot {
 static int i;
 public static void main(String[] args) throws AWTException, InterruptedException{
    // TODO Auto-generated method stub
     Thread.sleep(500);
 for (int i=0; i< 30; i+=1) {

    String str = " " + i + " ";
    Robot r = new Robot();
    Thread.sleep(200);
    String text = str;
    StringSelection stringSelection = new StringSelection(text);
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(stringSelection, stringSelection);
    Thread.sleep(200);
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_C);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_C);
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_V);
    
 } 

 }




 }

容易转换

for (int i=0; i< 30; i+=1) {

String str = " " + i + " ";

而是与强硬顺序合作? 我曾尝试过一段时间,没有任何工作。 甚至 = = 吨t允许其汇编。

问题回答

...... I m 试图使 Java输出“a”和“zzzz”之间的每一序列信函:

Use a for-loop to iterate from a to z.
Here is an example for a through zzz, which generates 18,278 values.

List<String> list = new ArrayList<>();
for (char c1 =  a ; c1 <=  z ; c1++) {
    list.add(String.valueOf(c1));
    for (char c2 =  a ; c2 <=  z ; c2++) {
        list.add("%s%s".formatted(c1, c2));
        for (char c3 =  a ; c3 <=  z ; c3++)
            list.add("%s%s%s".formatted(c1, c2, c3));
    }
}
list.sort(Comparator.comparing(String::length));

页: 1 我急于这样做,以便顺利地与 in一道工作,但 Java却不易转换到Sting或果园。 ......

转换很简单,这里指的是将int改为char/em>。

int a = 97;
char c = (char) a;

而且,如何将int改为char,然后改为String>。

int b = 98;
String s = String.valueOf((char) b);

页: 1 可轻易转换......

在提出清单后,你只能对每个项目进行核对。

public static void main2(String[] args) throws AWTException, InterruptedException{
    // TODO Auto-generated method stub
    Thread.sleep(500);
    List<String> list = new ArrayList<>();
    for (char c1 =  a ; c1 <=  z ; c1++) {
        list.add(String.valueOf(c1));
        for (char c2 =  a ; c2 <=  z ; c2++) {
            list.add("%s%s".formatted(c1, c2));
            for (char c3 =  a ; c3 <=  z ; c3++)
                list.add("%s%s%s".formatted(c1, c2, c3));
        }
    }
    list.sort(Comparator.comparing(String::length));
    for (String str : list) {
        Robot r = new Robot();
        Thread.sleep(200);
        String text = str;
        StringSelection stringSelection = new StringSelection(text);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, stringSelection);
        Thread.sleep(200);
        Robot robot = new Robot();
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_C);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_C);
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_V);

    }
}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签