【发布时间】:2021-05-16 07:02:39
【问题描述】:
我不确定为什么会这样,但在我的 IDE 中,对于 file.createNewFile();,我得到了 Result of 'File.createNewFile()' is ignored,我不知道我应该做什么
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
public class SQL {
public Connection connection;
public SQL(File file) {
try {
file.createNewFile(); // Result of 'File.createNewFile()' is ignored
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:" + file.getAbsolutePath());
} catch(Exception exception) {
exception.printStackTrace();
}
}
}
【问题讨论】: