當前位置: 首頁>>代碼示例>>Java>>正文


Java Files.notExists方法代碼示例

本文整理匯總了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) {}
}
 
開發者ID:StreamerSpectrum,項目名稱:BeamTeamDiscordBot,代碼行數:17,代碼來源:ConstellationManager.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:ExcludeJmodSectionPluginTest.java

示例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();
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:17,代碼來源:Config.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:Basic.java

示例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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:31,代碼來源:PgImport.java

示例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");

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:BasicTest.java

示例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;
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:37,代碼來源:BackpackManager.java

示例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");
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:37,代碼來源:VerifyJimage.java

示例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;
    }
}
 
開發者ID:musfiqus,項目名稱:student_database,代碼行數:13,代碼來源:DatabaseHelper.java

示例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;
}
 
開發者ID:Zymr,項目名稱:visitormanagement,代碼行數:14,代碼來源:Util.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:ImageModules.java

示例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;
}
 
開發者ID:wso2,項目名稱:message-broker,代碼行數:10,代碼來源:SslHandlerFactory.java

示例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);
    }
  }
}
 
開發者ID:strykeforce,項目名稱:thirdcoast,代碼行數:13,代碼來源:TalonProvisioner.java

示例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"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:AllModulePath.java


注:本文中的java.nio.file.Files.notExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。