this method uses a stringbuilder to create a new path for children. This
is faster than string appends ( str1 + str2).

@param oa
OutputArchive to write to.
@param path
a string builder.
@throws IOException
@throws InterruptedException
179935
void serializeNode(OutputArchive oa, StringBuilder path) throws IOException {
        String pathString = path.toString();
        DataNode node = getNode(pathString);
        if (node == null) {
            return;
        }
        String children[] = null;
        synchronized (node) {
            scount++;
            oa.writeString(pathString, "path");
            oa.writeRecord(node, "node");
            Set<String> childs = node.getChildren();
            if (childs != null) {
                children = childs.toArray(new String[childs.size()]);
            }
        }
        path.append('/');
        int off = path.length();
        if (children != null) {
            for (String child : children) {
                // since this is single buffer being resused
                // we need
                // to truncate the previous bytes of string.
                path.delete(off, Integer.MAX_VALUE);
                path.append(child);
                serializeNode(oa, path);
            }
        }
    }
905860
private File createNewFile(String path) throws IOException {

		// In windows, pathnames with spaces are returned as %20
		if (path.contains("%20"))
			path = path.replaceAll("%20", " ");
		File newFile = new File(path);

		if (!newFile.exists() && !newFile.createNewFile()) {
			throw new BundlingProcessException("Unable to create a temporary file at " + path);
		}

		if (LOGGER.isDebugEnabled())
			LOGGER.debug("Created file: " + newFile.getCanonicalPath());
		return newFile;
	}
321345
@Override
  public List<String> getAllChildren(String path) throws InterruptedException, KeeperException
  {
    return findAllChildren(path);
  }
1151187
@SuppressWarnings("unchecked")
    @Override
    public <T> T runScript(String path) throws IOException {
        List<URL> urls = Paths.toURLs(path);
        Object result = null;
        for (URL url : urls) {
            try (Reader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
                result = runScript(reader, url.getPath());
            }
        }
        return (T) result;
    }
1052042
void createDirectory(Path path) throws IOException {
		if (Files.exists(path) && Files.isDirectory(path)) {
			return;
		}

		if (this.readOnly) {
			throw new FileNotFoundException(
					"The requested directory \""
							+ path.toString()
							+ "\" does not exist and we are in read-only mode, so it cannot be created.");
		}

		Files.createDirectory(path);
	}
356588
private static void joinPath(StringBuilder path, String parent, String child)
    {
        // Add parent piece, with no trailing slash.
        if ( (parent != null) && (parent.length() > 0) )
        {
            if ( !parent.startsWith(PATH_SEPARATOR) )
            {
                path.append(PATH_SEPARATOR);
            }
            if ( parent.endsWith(PATH_SEPARATOR) )
            {
                path.append(parent.substring(0, parent.length() - 1));
            }
            else
            {
                path.append(parent);
            }
        }

        if ( (child == null) || (child.length() == 0) || (child.equals(PATH_SEPARATOR)) )
        {
            // Special case, empty parent and child
            if ( path.length() == 0 )
            {
                path.append(PATH_SEPARATOR);
            }
            return;
        }

        // Now add the separator between parent and child.
        path.append(PATH_SEPARATOR);

        if ( child.startsWith(PATH_SEPARATOR) )
        {
            child = child.substring(1);
        }

        if ( child.endsWith(PATH_SEPARATOR) )
        {
            child = child.substring(0, child.length() - 1);
        }

        // Finally, add the child.
        path.append(child);
    }
852170
protected String findClasspathFile(final String path) throws IOException {
        if (path == null){
            return null;
        }
        final File file = new File(path);
        if (file.exists()){
            return file.getAbsolutePath();
        }
        return createTmpFile(path).getAbsolutePath();
    }
828644
public WritableByteChannel create(URI path) throws IOException {
    logger.atFine().log("create(%s)", path);
    return create(path, CreateFileOptions.DEFAULT);
  }
1318535
public void writeFile(String aFilePath, byte[] aData, boolean append) throws IOException
   {
      Object lock = retrieveLock(aFilePath);      
      synchronized (lock) 
      {
         IO.writeFile(aFilePath, aData,append);
      }
   
   }
41072
private void initFileDirTables(Path path) throws IOException {
    FileStatus[] stats = fs.listStatus(path);
    if (stats != null) {
      for (FileStatus stat : stats) {
        if (stat.isDir()) {
          dirs.add(stat.getPath().toString());
          initFileDirTables(stat.getPath());
        } else {
          Path filePath = stat.getPath();
          if (filePath.getName().startsWith(StructureGenerator.FILE_NAME_PREFIX)) {
            files.add(filePath.toString());
          }
        }
      }
    }
  }
273115
public Resource addPath(String path)
        throws IOException,MalformedURLException
    {
        if (path==null)
            return null;

        path = URI.canonicalPath(path);

        return newResource(URI.addPaths(_url.toExternalForm(),path));
    }
968844
public void writeToFile(Path path) {
        try {
            try (OutputStream os = Files.newOutputStream(path)) {
                InputStreams.transferTo(body(), os);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
529963
@GwtIncompatible("Unnecessary")
  private Writer openExternExportsStream(B options, String path) throws IOException {
    if (options.externExportsPath == null) {
      return null;
    }

    String exPath = options.externExportsPath;

    if (!exPath.contains(File.separator)) {
      File outputFile = new File(path);
      exPath = outputFile.getParent() + File.separatorChar + exPath;
    }

    return fileNameToOutputWriter2(exPath);
  }
1034956
public static void writeAndClose(String path) throws InvocationTargetException, NoSuchMethodException,
            IllegalAccessException, IOException {
        writeTo(path);
        xssfWorkbook.close();
        createXssfWorkbook();
    }
864834
@Override
    public void setPath ( String path ) {
        if ( path.length() > 0 && path.charAt(0) == '\\' ) {
            path = path.substring(1);
        }
        // win8.1 returns ACCESS_DENIED if the trailing backslash is included
        if ( path.length() > 1 && path.charAt(path.length() - 1) == '\\' ) {
            path = path.substring(0, path.length() - 1);
        }
        this.name = path;
    }
810602
public FSDataOutputStream createFSDataOutputStream(String path) throws IOException {
        return fs.create(new Path(path), false);
    }
207393
@Override
  public ZKData<String> getZKStringData(String path) throws InterruptedException, KeeperException
  {
    return getZKStringData(path, null);
  }