Java Utililty Methods Path Create

List of utility methods to do Path Create

  1. HOME
  2. Java
  3. P
  4. Path Create

Description

The list of methods to do Path Create are organized into topic(s).

Method

String makePath(Collection files)
make Path
return makePath(files, File.pathSeparator);
void makePath(File copyTo)
make Path
File p = copyTo.getParentFile();
if (p == null) {
 return;
if (!p.exists()) {
 if (!p.mkdirs()) {
 throw new IOException("Could not create directory: " + p.getAbsolutePath());
String makePath(File cwd, String path)
make Path
String prefix = "", suffix = "";
if (path.startsWith("jar:file:")) {
 prefix = "jar:file:";
 int exclamation = path.indexOf('!');
 suffix = path.substring(exclamation);
 path = path.substring(prefix.length(), exclamation);
if (isAbsolutePath(path))
...
String makePath(final String dir, final String... jars)
make Path
StringBuilder sb = new StringBuilder();
for (String jar : jars) {
 if (sb.length() > 0)
 sb.append(File.pathSeparator);
 sb.append(dir).append(File.separator).append(jar);
return sb.toString();
void makePath(String basePath)
Makes folders along the specified path
File path = new File(basePath);
try {
 if (!path.exists()) {
 if (!path.mkdirs())
 if (!path.exists())
 throw new RuntimeException("Failed to create directory:" + basePath);
 } else if (!path.isDirectory()) {
 throw new RuntimeException("Something is already has this name, and it's not a dir: " + basePath);
...
String makePath(String filename, String savePath)
make Path
int hashcode = filename.hashCode();
int dir1 = hashcode & 0xf; 
int dir2 = (hashcode & 0xf0) >> 4; 
String dir = savePath + File.separator + dir1 + File.separator + dir2;
File file = new File(dir);
if (!file.exists()) {
 file.mkdirs();
 file.setWritable(true, false);
...
String makePath(String path1, String path2)
make Path
if (path1.endsWith(File.separator))
 return path1 + path2;
return path1 + File.separator + path2;
String makePath(String... elements)
Construct a file path from the given elements, i.e.
return String.join(File.separator, elements);
String makePath(String... elements)
Construct a file path from the given elements, i.e.
return join(File.separator, elements);
String makePath(String[] strings)
Convert a list of path elements to a platform-specific path.
String result = "";
for (int i = 0; i < strings.length; i++)
 result += File.separator + strings[i];
return result;


AltStyle によって変換されたページ (->オリジナル) /