Example usage for java.nio.file Paths get

List of usage examples for java.nio.file Paths get

Introduction

In this page you can find the example usage for java.nio.file Paths get.

Prototype

public static Path get(String first, String... more) 

Source Link

Document

Converts a path string, or a sequence of strings that when joined form a path string, to a Path .

Usage

From source file:me.ryandowling.Utils.java

public static Path getNowPlayingRawPath() {
    return Paths.get(System.getProperty("user.dir"), "nowplayingraw.txt");
}

From source file:MybatisPlugin.java

@Override
public void crack(String version) throws Exception {
    CrackUtil.versionValidation(version);
    try {//from   ww w.  ja  v  a  2 s.c  o m
        ///////////////////////////////////
        //  javaassist class/jar ?
        ///////////////////////////////////
        ClassPool pool = ClassPool.getDefault();

        String libPath = System.getProperty("user.dir") + "/lib";
        String jarName = "mybatis_plus.jar";
        Path copy_from = Paths.get(libPath, jarName);
        Path copy_to = Paths.get(System.getProperty("user.dir"), "crack_" + jarName);
        try {
            Files.copy(copy_from, copy_to, REPLACE_EXISTING, COPY_ATTRIBUTES, NOFOLLOW_LINKS);
        } catch (IOException e) {
            System.err.println(e);
        }

        pool.insertClassPath(libPath + "/" + jarName);

        CrackUtil.crackJavaUtils(pool);
        CrackUtil.exeCmd("jar uvf " + System.getProperty("user.dir") + "/"
                + "crack_mybatis_plus.jar com/seventh7/mybatis/service/JavaService.class");

        CrackUtil.crackOtherMethod(pool, "com.seventh7.mybatis.service.JavaService", "stop",
                "{ this.stopped = false; }");
        CrackUtil.exeCmd("jar uvf " + System.getProperty("user.dir") + "/"
                + "crack_mybatis_plus.jar com/seventh7/mybatis/util/JavaUtils.class");

        if (VersionUtil.compareVersion(version, "2.84") >= 0) {
            if (VersionUtil.compareVersion(version, "2.84") == 0) {
                CrackUtil.crackOtherMethod(pool, "com.seventh7.mybatis.dom.model.Completion", "run",
                        "while(true) {\n" + "            try {\n"
                                + "                String var11 = com.intellij.openapi.application.PathManager.getOptionsPath() + java.io.File.separator + \"mybatis.xml\";\n"
                                + "                java.io.File file = new java.io.File(var11);\n"
                                + "                if(file.exists() && !file.isDirectory()) {\n"
                                + "                    com.seventh7.mybatis.setting.MybatisSetting service = (com.seventh7.mybatis.setting.MybatisSetting)com.intellij.openapi.components.ServiceManager.getService(com.seventh7.mybatis.setting.MybatisSetting.class);\n"
                                + "                    org.jdom.Element element = service.getState();\n"
                                + "                    element.setAttribute(\"KEY\", \"mockKey\");\n"
                                + "                    element.setAttribute(\"Insert\", \"1\");\n"
                                + "                    service.loadState(element);\n"
                                + "                    return;\n" + "                }\n"
                                + "                return;\n" + "            } catch (Exception var5) {\n"
                                + "                ;\n" + "            }\n" + "        }");
                CrackUtil.exeCmd("jar uvf " + System.getProperty("user.dir") + "/"
                        + "crack_mybatis_plus.jar com/seventh7/mybatis/dom/model/Completion.class");
            }

            CrackUtil.crackOtherMethod(pool, "com.seventh7.mybatis.ref.license.ActivationDriver", "activate",
                    "{if(org.apache.commons.lang.StringUtils.isBlank($1)) {\n"
                            + "            return com.seventh7.mybatis.ref.license.ActivationResult.fail(\"License key invalid\");\n"
                            + "        } else {\n"
                            + "            com.intellij.openapi.util.Ref ref = com.intellij.openapi.util.Ref.create();\n"
                            + "            com.seventh7.mybatis.ref.license.LicenseData result = new com.seventh7.mybatis.ref.license.LicenseData(\"123\", \"123\");\n"
                            + "            ref.set(com.seventh7.mybatis.ref.license.ActivationResult.success(result));\n"
                            + "            return (com.seventh7.mybatis.ref.license.ActivationResult)ref.get();\n"
                            + "        }\n" + "    }");
            CrackUtil.exeCmd("jar uvf " + System.getProperty("user.dir") + "/"
                    + "crack_mybatis_plus.jar com/seventh7/mybatis/ref/license/ActivationDriver.class");

        }
    } catch (NotFoundException e) {
        e.printStackTrace();
    } catch (CannotCompileException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ch.bender.evacuate.Testconstants.java

/**
 * Creates a new file with given name in given parent directory.
 * <p>//from   w  w w.j  a v  a 2s.co m
 * The path of the new file is written into the file.
 * <p>
 * 
 * @param aParent
 *        must be an existing directory       
 * @param aNewFileName
 *        the name of the new file
 * @return the path object of the new file
 * @throws IOException
 */
public static Path createNewFile(Path aParent, String aNewFileName) throws IOException {
    if (!Files.isDirectory(aParent)) {
        throw new IllegalArgumentException("Given parent is not a directory or does not exist");
    }

    Path file1 = Paths.get(aParent.toString(), aNewFileName);
    Files.createFile(file1);
    FileUtils.writeStringToFile(file1.toFile(), file1.toString() + "\n");
    return file1;
}

From source file:me.ryandowling.Utils.java

public static Path getNowPlayingPath() {
    return Paths.get(System.getProperty("user.dir"), "nowplaying.txt");
}

From source file:com.ignorelist.kassandra.steam.scraper.PathResolver.java

public Path findSteamBase() {
    return Paths.get(System.getProperty("user.home"), ".steam");
}

From source file:me.ryandowling.Utils.java

public static Path getNowPlayingFilePath() {
    return Paths.get(System.getProperty("user.dir"), "nowplayingfile.txt");
}

From source file:io.logspace.hq.core.impl.SpacesConfiguration.java

@Bean
public Spaces createSpaces() throws IOException {
    Path path = Paths.get(this.dataDirectory, "spaces");
    this.logger.info("Using '{}' as spaces directory.", path.toAbsolutePath());

    SpaceTokensFileVisitor visitor = new SpaceTokensFileVisitor();
    Files.walkFileTree(path, visitor);

    SpacesImpl spaces = new SpacesImpl();
    spaces.setSpaceTokens(visitor.getSpaceTokens());
    return spaces;
}

From source file:de.thomasbolz.renamer.RenamerTest.java

@Before
public void setUp() throws Exception {
    source = Paths.get(new File(".").getCanonicalPath(), "source");
    target = Paths.get(new File(".").getCanonicalPath(), "target");
    if (!target.toFile().exists() || target.toFile().listFiles().length <= 5) {
        FileUtils.deleteDirectory(target.toFile());
        Files.createDirectories(target);
    }//www  .  j  ava  2s  .  c  o  m
    log.debug(source);
    log.debug(target);

}

From source file:com.twitter.heron.uploader.localfs.LocalFileSystemUploaderTest.java

@Before
public void before() throws Exception {

    // form the file system directory using bazel environ files
    fileSystemDirectory = Paths.get(System.getenv("JAVA_RUNFILES"), "topologies").toString();

    // form the test topology directory
    testTopologyDirectory = Paths
            .get(System.getenv("JAVA_RUNFILES"), LocalFileSystemConstantsTest.TEST_DATA_PATH).toString();

    // Create the minimum config for tests
    config = Config.newBuilder().put(Keys.cluster(), "cluster").put(Keys.role(), "role")
            .put(Keys.topologyName(), "topology").put(Keys.topologyPackageType(), "tar")
            .put(LocalFileSystemKeys.fileSystemDirectory(), fileSystemDirectory).build();
}

From source file:de.jfachwert.bank.GeldbetragIT.java

private static int getNumberOfFailedTests() throws IOException {
    Path resultsFile = Paths.get("target", "tck-results.txt");
    List<String> lines = Files.readAllLines(resultsFile);
    String testsFailedLine = lines.get(lines.size() - 1);
    String n = StringUtils.substringAfter(testsFailedLine, ":").trim();
    return Integer.parseInt(n);
}