Package java.nio.file

Examples of java.nio.file.Path


    int rand = new Random().nextInt(99999);
   
    // Write to temp files and parse again to compare:
    for (Syntax syntax : writerSyntaxes) {
      final Path FILE = Files.createTempFile("foaf." + rand, syntax.getFilenameExtension());
      try {
        test.writeTo(Files.newOutputStream(FILE), syntax);
        test.writeTo(System.out, syntax);
 
        Model model = getModelFactory().createModel().open();
View Full Code Here


        }
    }

    public void testInitialDeploymentGlossesOverSymlinksInParents() throws Exception {
        //java7 API, but we're in tests, and require java7 to build anyway
        Path root = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".symlink-root", null).toPath();
        Path symlinkTarget = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".symlink-target", null)
            .toPath();

        File src = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".src", null);

        Path parent = root.resolve("parent");
        parent.toFile().mkdirs();

        try {
            File destination = null;

            try {
                destination = Files.createSymbolicLink(parent.resolve("destination"), symlinkTarget).toFile();
            } catch (UnsupportedOperationException e) {
                LOG.info("Skipping testInitialDeploymentGlossesOverSymlinksInParents. The current filesystem doesn't support symlinks");
                return;
            }

            // put some source files in our tmpDirSrc location
            File testRawFileA = new File(src, "updater-testA.txt");
            File testRawFileA2 = new File(src, "updater-testA2.txt");
            File testRawFileB = new File(src, "updater-testB.txt");
            File testRawFileADest = new File(destination, "../realDest/rawA.txt");
            File testRawFileA2Dest = new File(destination, "../realDest/rawA2.txt");
            File testRawFileBDest = new File(destination, "../../realDest/rawB.txt");
            FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA);
            FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA2);
            FileUtil.copyFile(new File("target/test-classes/updater-testB.txt"), testRawFileB);

            DeploymentProperties deploymentProps = new DeploymentProperties(0, "testbundle", "1.0.test", null,
                DestinationComplianceMode.full);
            HashMap<File, File> zipFiles = null;
            Map<File, File> rawFiles = new HashMap<File, File>(3);
            rawFiles.put(testRawFileA, testRawFileADest);
            rawFiles.put(testRawFileA2, testRawFileA2Dest);
            rawFiles.put(testRawFileB, testRawFileBDest);

            DeploymentData dd = new DeploymentData(deploymentProps, src, destination, rawFiles, null, zipFiles, null,
                templateEngine, null, null);
            Deployer deployer = new Deployer(dd);
            DeployDifferences diff = new DeployDifferences();
            FileHashcodeMap map = deployer.deploy(diff);
            System.out.println("map-->\n" + map);
            System.out.println("diff->\n" + diff);

            assert map.size() == 3 : map;

            assert parent.resolve("realDest/rawA.txt").toFile().exists() : "rawA.txt not deployed correctly";
            assert parent.resolve("realDest/rawA2.txt").toFile().exists() : "rawA2.txt not deployed correctly";
            assert root.resolve("realDest/rawB.txt").toFile().exists() : "rawB.txt not deployed correctly";

            //the symlink target, being the destination of the deployment should have the .rhqdeployments directory
            //specified. No other files should exist there though.
            assert symlinkTarget.resolve(".rhqdeployments").toFile().exists() : "Could not find .rhqdeployments on the expected location";
View Full Code Here

    @After
    public void cleanup()
        throws Exception
    {
        super.tearDown();
        Path tmpIndexDir = Paths.get( System.getProperty( "java.io.tmpdir" ), "tmpIndex" );
        if ( Files.exists( tmpIndexDir ) )
        {
            FileUtils.deleteDirectory( tmpIndexDir.toFile() );
        }
    }
View Full Code Here

    protected String createAndScanRepo()
        throws Exception
    {

        Path tmpIndexDir = Paths.get( System.getProperty( "java.io.tmpdir" ), "tmpIndex" );
        if ( Files.exists( tmpIndexDir ) )
        {
            FileUtils.deleteDirectory( tmpIndexDir.toFile() );
        }
        String id = Long.toString( System.currentTimeMillis() );
        ManagedRepository managedRepository = new ManagedRepository();
        managedRepository.setId( id );
        managedRepository.setName( "name of " + id );
View Full Code Here

    @Test
    public void downloadMergedIndex()
        throws Exception
    {
        Path tmpIndexDir = Paths.get( System.getProperty( "java.io.tmpdir" ), "tmpIndex" );
        if ( Files.exists( tmpIndexDir ) )
        {
            FileUtils.deleteDirectory( tmpIndexDir.toFile() );
        }
        String id = Long.toString( System.currentTimeMillis() );
        ManagedRepository managedRepository = new ManagedRepository();
        managedRepository.setId( id );
        managedRepository.setName( "name of " + id );
View Full Code Here

     *
     * @since   1.7
     * @see Path#toFile
     */
    public Path toPath() {
        Path result = filePath;
        if (result == null) {
            synchronized (this) {
                result = filePath;
                if (result == null) {
                    result = FileSystems.getDefault().getPath(path);
View Full Code Here

        if (null == path) {
            return null;
        }
        try {
            path = path.trim();
            final Path dir = Paths.get(path.length() == 0 ? "." : path);
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
                    @Override
                    public Void run() {
                        validateDumpDir(dir);
                        return null;
View Full Code Here

        return sb.toString();
    }

    public void dumpClass(String className, final byte[] classBytes) {
        Path file;
        try {
            file = dumpDir.resolve(encodeForFilename(className) + ".class");
        } catch (InvalidPathException ex) {
            PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
                          .warning("Invalid path for class " + className);
            return;
        }

        try {
            Path dir = file.getParent();
            Files.createDirectories(dir);
            Files.write(file, classBytes);
        } catch (Exception ignore) {
            PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
                          .warning("Exception writing to path at " + file.toString());
View Full Code Here

    }
    return content;
  }

  private String getOwnerOfFile(File file) {
    Path path = FileSystems.getDefault().getPath(file.getParent(), file.getName());
    try {
      return Files.getOwner(path).getName();
    } catch (IOException e) {
      logger.error("Failed to obtain owner of file " + file.getAbsoluteFile() + " with message " + e.getMessage());
      return null;
View Full Code Here

    private static final Logger LOG = Logger.getLogger(PicturesBean.class);

    public List<Picture> getPictures() {
        List<Picture> result = new ArrayList<>();

        Path picturePath = Paths.get("C:/Benutzer/Theo/Eiegene Bilder");
        try
        {
            for (Path pictureFile : DirectoryScanner.scan(picturePath))
            {
                Picture picture = new Picture(pictureFile, pictureFile.getFileName().toString());
View Full Code Here

TOP

Related Classes of java.nio.file.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.