Java File Path Create buildPath(long id, boolean justDir)

Here you can find the source of buildPath(long id, boolean justDir)

Description

build Path

License

Apache License

Declaration

private static String buildPath(long id, boolean justDir) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static String buildPath(long id, boolean justDir) {
        StringBuilder fileBuffer = new StringBuilder();
        fileBuffer.append(id);//from   www. ja  v a 2 s  .co  m
        // Pad out e.g. 10100 -> 010100
        while ((fileBuffer.length() % 3) != 0) {
            fileBuffer.insert(0, '0');
        }
        StringBuilder dirBuffer = new StringBuilder();
        for (int i = 0; i < fileBuffer.length() - 3; i += 3) {
            dirBuffer.append(fileBuffer.subSequence(i, i + 3));
            dirBuffer.append("/");
        }

        if (justDir) {
            return dirBuffer.toString();
        } else {
            return dirBuffer.toString() + fileBuffer.toString();
        }
    }
}

Related

  1. buildPath(final boolean endWithSep, final String... val)
  2. buildPath(final String basePath, final String path)
  3. buildPath(final String... tokens)
  4. buildPath(Integer sAccountId, String objectPath)
  5. buildPath(String first, String... parts)
  6. buildPath(String part1, String part2)
  7. buildPath(String path, String file)
  8. buildPath(String... paths)