我正在尝试创建一种方法,可以在给定列之后找到下一列。例如:
input: A
output: B
Run Code Online (Sandbox Code Playgroud)
乍一看似乎很简单。我只是打算使用以下方法:
public static char nextLetter(char c) {
c++;
return c;
}
Run Code Online (Sandbox Code Playgroud)
当你过去Z列在谷歌表,列Z后,就会出现问题,列名是两个字母,然后是三个,等于是柱后Z谈到AA,后AZ来BA,后ZZ来AAA,等我的下一个念头,就是首先要弄清楚索引方面的列位置。所以列AA将是 27、52BA等。
查找列的索引不是我现在面临的问题。我需要弄清楚如何将该索引转换为相应的列名。我打算尝试以下方法,但我意识到它也仅限于 AZ:
public static char getLetter(int index) {
return (char) (index + 64);
}
Run Code Online (Sandbox Code Playgroud)
在这一点上,我认为需要一种递归方法。但是,我无法弄清楚如何设置它。这是我得到的:
private static void getNotation(int size) {
int divided = size / 26;
int remainder = size % 26;
String notation = "";
while (divided % 26 > 0) {
// Here …Run Code Online (Sandbox Code Playgroud) 我遇到了 Selenium WebDriver 的 WebSocket 问题,这里描述了同样的问题。问题的解决方案是将--remote-allow-origins=*参数添加到我的驱动程序的 ChromeOptions 中。但是,我不想为此参数使用通配符。我想将其设置为仅允许来自我的应用程序的连接。
我相信解决方案将涉及预先确定 WebDriver 的端口。这是我最好的尝试,但它不起作用:
ChromeOptions options = new ChromeOptions();
options.addArguments("--incognito", "--app=" + linkedform);
int port;
try (ServerSocket serverSocket = new ServerSocket(0)) {
port = serverSocket.getLocalPort();
} catch (IOException e) {
throw new RuntimeException(e);
}
options.addArguments("--remote-allow-origins=http://localhost:" + port);
ChromeDriverService service = new ChromeDriverService.Builder().usingPort(port).build();
this.chrome = new ChromeDriver(service, options);
Run Code Online (Sandbox Code Playgroud)
我走在正确的道路上吗?这可能吗?
java google-chrome google-chrome-devtools selenium-chromedriver selenium-webdriver
如果我有这样的配置,可以使用吗?
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "FOREIGN_ID", nullable = false, insertable = false, updatable = false)
ForeignClass foreignClass;
Run Code Online (Sandbox Code Playgroud)
我认为不是,因为级联类型的行为与可插入和可更新参数相冲突。
你怎么认为?
java hibernate hibernate-mapping spring-data spring-data-jpa
如何在String不使用BufferedReader?的情况下逐行读取文本文件的内容?
例如,我有一个看起来像这样的文本文件:
Purlplemonkeys
greenGorilla
Run Code Online (Sandbox Code Playgroud)
我想创建两个strings,然后使用这样的东西
File file = new File(System.getProperty("user.dir") + "\Textfile.txt");
String str = new String(file.nextLine());
String str2 = new String(file.nextLine());
Run Code Online (Sandbox Code Playgroud)
这样它就分配str了值"Purlplemonkeys"和str2值"greenGorilla".