Package java.io

Examples of java.io.File.toPath()


        byte[] data = Files.readSymbolicLink(file.toPath()).toString().getBytes();
        item.setChecksum(createChecksum(data));
        return data;
      } else if (item.isType(ItemType.FILE)) {

        byte[] data = Files.readAllBytes(file.toPath());
        item.setChecksum(createChecksum(data));
        return data;
      }
      return null;
    } catch (final IOException e) {
View Full Code Here


  @Override
  protected int doCommand(JSAPResult parsedArgs) throws CommandArgumentsException, CommandOperationException {
    String bundleDir = parsedArgs.getString("bundle-dir");
    boolean showAllDependencies = parsedArgs.getBoolean("all");
    File bundlableDir = brjs.file("sdk/" + bundleDir);
    String relativePath = brjs.file("sdk").toPath().relativize(bundlableDir.toPath()).toString().replace("\\", "/");
   
    if(!bundlableDir.exists()) throw new DirectoryDoesNotExistCommandException(relativePath, this);
   
   
    try {
View Full Code Here

        if (!OS.IS_WINDOWS)
        {
            context.clearAliasChecks();
           
            Files.createSymbolicLink(link.toPath(),foobar.toPath());
            response = connector.getResponses("GET /context/link.txt HTTP/1.0\r\n\r\n");
            assertResponseContains("404", response);
           
            context.addAliasCheck(new AllowSymLinkAliasChecker());
           
View Full Code Here

        // we can't just use whatever is the OS default.
        // because, for example, a windows system using git can be configured for EOL handling using
        // local, remote, file lists, patterns, etc, rendering assumptions about the OS EOL choice
        // wrong for unit tests.
        LN = System.getProperty("line.separator");
        try (BufferedReader reader = Files.newBufferedReader(big.toPath(),StandardCharsets.UTF_8))
        {
            // a buffer large enough to capture at least 1 EOL
            char cbuf[] = new char[128];
            reader.read(cbuf);
            String sample = new String(cbuf);
View Full Code Here

            // send "small" files blocking directly from an input stream
            if (file.length() < SMALL)
            {
                // need to caste to Jetty output stream for best API
                ((HttpOutput) response.getOutputStream())
                        .sendContent(FileChannel.open(file.toPath(),
                                StandardOpenOption.READ));
                return;
            }

            // send not "small" files asynchronously so we don't hold threads if
View Full Code Here

            // send "medium" files from an input stream
            if (file.length() < MEDIUM)
            {
                // the file channel is closed by the async send
                ((HttpOutput) response.getOutputStream())
                        .sendContent(FileChannel.open(file.toPath(),
                                StandardOpenOption.READ), completionCB);
                return;
            }

            // for "large" files get the file mapped buffer to send Typically
View Full Code Here

       
        if (OS.IS_UNIX)
        {
            // Create alias as 8.3 name so same test will produce an alias on both windows an normal systems
            File eightDotThree=new File(sub,"TEXTFI~1.TXT");
            Files.createSymbolicLink(eightDotThree.toPath(),verylong.toPath());
           
            Files.createSymbolicLink(new File(docroot,"other").toPath(),new File("../transit").toPath());
            Files.createSymbolicLink(transit.toPath(),otherroot.toPath());
        }
       
View Full Code Here

                    // It's a file.
                    if (resource.startsWith("./"))
                        resource=resource.substring(2);
                   
                    File file=new File(resource).getCanonicalFile();
                    return new PathResource(file.toPath());
                }
                catch(Exception e2)
                {
                    LOG.debug(Log.EXCEPTION,e2);
                    throw e;
View Full Code Here

{
    @Test
    public void testCanReadDirectory()
    {
        File targetDir = MavenTestingUtils.getTargetDir();
        Assert.assertTrue("Can read dir: " + targetDir,FS.canReadDirectory(targetDir.toPath()));
    }

    @Test
    public void testCanReadDirectory_NotDir()
    {
View Full Code Here

    @Test
    public void testCanReadDirectory_NotDir()
    {
        File bogusFile = MavenTestingUtils.getTestResourceFile("bogus.xml");
        Assert.assertFalse("Can read dir: " + bogusFile,FS.canReadDirectory(bogusFile.toPath()));
    }

    @Test
    public void testCanReadFile()
    {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.