本文整理汇总了Java中java.nio.file.Files.notExists方法的典型用法代码示例。如果您正苦于以下问题:Java Files.notExists方法的具体用法?Java Files.notExists怎么用?Java Files.notExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.Files
的用法示例。
在下文中一共展示了Files.notExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAnnouncements
import java.nio.file.Files; //导入方法依赖的package包/类
private static void handleAnnouncements(LiveEvent event, JsonObject payload) {
try {
if (Files.notExists(Paths.get("payloads\\"))) {
new File("payloads\\").mkdir();
}
Logger logger = Logger.getLogger("payload-announcement");
FileHandler fh = new FileHandler("payloads\\" + logger.getName() + ".json");
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
logger.addHandler(fh);
logger.log(Level.INFO, payload.toString());
} catch (SecurityException | IOException e) {}
}
示例2: createImage
import java.nio.file.Files; //导入方法依赖的package包/类
private Path createImage(String outputDir, List<String> options,
List<String> expectedFiles) {
System.out.println("jlink " + options.toString());
int rc = JLINK_TOOL.run(System.out, System.out,
options.toArray(new String[0]));
assertTrue(rc == 0);
Path d = IMAGES_DIR.resolve(outputDir);
for (String fn : expectedFiles) {
Path path = d.resolve(fn);
if (Files.notExists(path)) {
throw new RuntimeException(path + " not found");
}
}
return d;
}
示例3: loadConfig
import java.nio.file.Files; //导入方法依赖的package包/类
public static void loadConfig(RPGInventory plugin) {
configFile = plugin.getDataPath().resolve("config.yml");
if (Files.notExists(configFile)) {
plugin.saveDefaultConfig();
try {
Path destination = plugin.getDataPath().resolve("config-example.yml");
Files.copy(configFile, destination, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}
plugin.reloadConfig();
Config.config = plugin.getConfig();
}
示例4: setup
import java.nio.file.Files; //导入方法依赖的package包/类
@BeforeClass
public void setup() {
theFileSystem = FileSystems.getFileSystem(URI.create("jrt:/"));
Path modulesPath = Paths.get(System.getProperty("java.home"),
"lib", "modules");
isExplodedBuild = Files.notExists(modulesPath);
if (isExplodedBuild) {
System.out.printf("%s doesn't exist.", modulesPath.toString());
System.out.println();
System.out.println("It is most probably an exploded build."
+ " Skip non-default FileSystem testing.");
return;
}
Map<String, String> env = new HashMap<>();
// set java.home property to be underlying java.home
// so that jrt-fs.jar loading is exercised.
env.put("java.home", System.getProperty("java.home"));
try {
fs = FileSystems.newFileSystem(URI.create("jrt:/"), env);
} catch (IOException ioExp) {
throw new RuntimeException(ioExp);
}
}
示例5: isPageComplete
import java.nio.file.Files; //导入方法依赖的package包/类
@Override
public boolean isPageComplete(){
//empty path: show default message
if (txtPath.getText().isEmpty()) {
setErrorMessage(null);
return false;
}
String err = null;
String name = txtName.getText();
if (name.isEmpty()) {
err = Messages.PgImport_error_no_name;
}
Path path = Paths.get(txtPath.getText());
if (Files.exists(path.resolve(FILE_PROJECT))) {
//if has .project
err = Messages.PgImportWizardImportPage_already_exist;
} else if (Files.exists(path.resolve(FILE_METADATA))) {
//if has .metadata
err = Messages.PgImport_error_metadata;
} else if (Files.notExists(path.resolve(ApgdiffConsts.FILENAME_WORKING_DIR_MARKER))) {
//if don't have .pgCodekeeper
err = Messages.PgImportWizardImportPage_no_project;
} else if (isInWorkspaceRoot(path) && !path.getFileName().toString().equals(name)) {
//if project in root of workspace, it must have default name
err = Messages.PgImport_error_default_name;
}
setErrorMessage(err);
return err == null;
}
示例6: flagDeletePos
import java.nio.file.Files; //导入方法依赖的package包/类
@Before
public void flagDeletePos() {
if (Files.notExists(Paths.get(".photos/"))) {
photosExist = false;
} else {
photosExist = true;
}
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-dorfner-v2,代码行数:9,代码来源:TestPhotos.java
示例7: run
import java.nio.file.Files; //导入方法依赖的package包/类
public void run() throws Throwable {
if (Files.notExists(jdkMods)) {
return;
}
if (!CompilerUtils.compile(src, classes)) {
throw new AssertionError("Compilation failure. See log.");
}
Files.createDirectories(jmods);
Files.createDirectories(jars);
Path jarfile = jars.resolve("test.jar");
JarUtils.createJarFile(jarfile, classes);
Path image = Paths.get("mysmallimage");
runJmod(jarfile.toString(), TEST_MODULE, true);
runJlink(image, TEST_MODULE, "--compress", "2", "--launcher", "foo=" + TEST_MODULE);
execute(image, "foo");
Files.delete(jmods.resolve(TEST_MODULE + ".jmod"));
image = Paths.get("myimage");
runJmod(classes.toString(), TEST_MODULE, true);
runJlink(image, TEST_MODULE, "--launcher", "bar=" + TEST_MODULE);
execute(image, "bar");
Files.delete(jmods.resolve(TEST_MODULE + ".jmod"));
image = Paths.get("myimage2");
runJmod(classes.toString(), TEST_MODULE, false /* no ModuleMainClass! */);
// specify main class in --launcher command line
runJlink(image, TEST_MODULE, "--launcher", "bar2=" + TEST_MODULE + "/jdk.test.Test");
execute(image, "bar2");
}
示例8: init
import java.nio.file.Files; //导入方法依赖的package包/类
public static boolean init(RPGInventory instance) {
if (!isEnabled()) {
return false;
}
try {
Path petsFile = RPGInventory.getInstance().getDataPath().resolve("backpacks.yml");
if (Files.notExists(petsFile)) {
RPGInventory.getInstance().saveResource("backpacks.yml", false);
}
FileConfiguration petsConfig = YamlConfiguration.loadConfiguration(petsFile.toFile());
BACKPACK_TYPES.clear();
for (String key : petsConfig.getConfigurationSection("backpacks").getKeys(false)) {
tryToAddBackpack(key, petsConfig.getConfigurationSection("backpacks." + key));
}
BackpackManager.loadBackpacks();
RPGInventory.getPluginLogger().info(BACKPACK_TYPES.size() + " backpack type(s) has been loaded");
RPGInventory.getPluginLogger().info(BACKPACKS.size() + " backpack(s) has been loaded");
} catch (Exception e) {
e.printStackTrace();
return false;
}
if (BACKPACK_TYPES.size() == 0) {
return false;
}
BACKPACK_LIMIT = Config.getConfig().getInt("backpacks.limit", 0);
// Register events
instance.getServer().getPluginManager().registerEvents(new BackpackListener(), instance);
return true;
}
示例9: main
import java.nio.file.Files; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
String home = System.getProperty("java.home");
Path bootimagePath = Paths.get(home, "lib", "modules");
if (Files.notExists(bootimagePath)) {
System.out.println("Test skipped, not an images build");
return;
}
long start = System.nanoTime();
int numThreads = Integer.getInteger("jdk.test.threads", 1);
JImageReader reader = newJImageReader();
VerifyJimage verify = new VerifyJimage(reader, numThreads);
if (args.length == 0) {
// load classes from jimage
verify.loadClasses();
} else {
Path dir = Paths.get(args[0]);
if (Files.notExists(dir) || !Files.isDirectory(dir)) {
throw new RuntimeException("Invalid argument: " + dir);
}
verify.compareExplodedModules(dir);
}
verify.waitForCompletion();
long end = System.nanoTime();
int entries = reader.entries();
System.out.format("%d entries %d files verified: %d ms %d errors%n",
entries, verify.count.get(),
TimeUnit.NANOSECONDS.toMillis(end - start), failed.size());
for (String f : failed) {
System.err.println(f);
}
if (!failed.isEmpty()) {
throw new AssertionError("Test failed");
}
}
示例10: checkDBFile
import java.nio.file.Files; //导入方法依赖的package包/类
public boolean checkDBFile() {
Path path = Paths.get(DB_NAME);
if (Files.exists(path)) {
System.out.println("Exists");
return true;
} else if (Files.notExists(path)) {
return false;
} else {
return false;
}
}
示例11: createFileDirectory
import java.nio.file.Files; //导入方法依赖的package包/类
/**
* @param baseDirName
* @param imageDirName
* @return
* @throws IOException
*/
public static Path createFileDirectory(String baseDirName, String...imageDirName) throws IOException{
Path path = Paths.get(baseDirName, imageDirName);
if (Files.notExists(path)) {
Files.createDirectories(path);
}
return path;
}
示例12: getJava
import java.nio.file.Files; //导入方法依赖的package包/类
static String getJava(Path image) {
boolean isWindows = System.getProperty("os.name").startsWith("Windows");
Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java");
if (Files.notExists(java))
throw new RuntimeException(java + " not found");
return java.toAbsolutePath().toString();
}
示例13: getPath
import java.nio.file.Files; //导入方法依赖的package包/类
private Path getPath(String storePath) {
Path path = Paths.get(storePath);
if (Files.notExists(path)) {
String brokerHome = System.getProperty(CommonConstants.MESSAGE_BROKER_HOME_PROPERTY);
path = Paths.get(brokerHome + File.separator + storePath);
}
return path;
}
示例14: checkFileExists
import java.nio.file.Files; //导入方法依赖的package包/类
static void checkFileExists(File file) {
Path path = file.toPath();
if (Files.notExists(path)) {
logger.info("{} missing, copying default", file);
InputStream is = TalonProvisioner.class.getResourceAsStream(DEFAULT_CONFIG);
try {
Files.copy(is, path);
} catch (IOException e) {
logger.error("unable to copy default config to " + path, e);
}
}
}
示例15: testAddModules
import java.nio.file.Files; //导入方法依赖的package包/类
@Test
public void testAddModules() throws Throwable {
if (Files.notExists(JMODS)) {
return;
}
// create custom image
Path image = Paths.get("image2");
createImage(image,
"--add-modules", "m1,test",
"--add-modules", "ALL-MODULE-PATH",
"--limit-modules", "java.base");
checkModules(image, Set.of("m1", "test", "java.base"));
}