Gets string as opt with classpath.

@param classpath   the classpath
@param charsetName the charset name
@return the string as opt with classpath
546642
public static Optional<String> getStringAsOptWithClasspath(
            String classpath, String charsetName) {
        return getResourceInputStreamAsOpt(classpath)
                .map(resourceInputStream -> JMInputStream
                        .toString(resourceInputStream, charsetName));
    }
16326
public static String getClassPath(boolean isEncoded) {
		final URL classPathURL = getClassPathURL();
		String url = isEncoded ? classPathURL.getPath() : URLUtil.getDecodedPath(classPathURL);
		return FileUtil.normalize(url);
	}
140886
public static String readString(String filePath, String charsetName) {
        return readString(getPath(filePath), charsetName);
    }
350504
public String optString(String name, String fallback) {
        return optString(name, fallback, true);
    }
1228328
public static File getFileFromClasspath(final String filePath) throws FileNotFoundException {
        try {
            URL fileURL = FileUtils.class.getClassLoader().getResource(filePath);
            if (fileURL == null) {
                throw new FileNotFoundException("File [" + filePath + "] could not be found in classpath");
            }
            return new File(fileURL.toURI());
        } catch (URISyntaxException e) {
            throw new FileNotFoundException("File [" + filePath + "] could not be found: " + e.getMessage());
        }
    }
8697
public static String readString(String path, Charset charset) throws IORuntimeException {
		return readString(file(path), charset);
	}
1107389
public static final Properties read(String classpath) throws IOException{
        final URL url = Resources.getResource(classpath);
        final ByteSource byteSource = Resources.asByteSource(url);
        final Properties properties = new Properties();
        InputStream inputStream = null;
        try {
            inputStream = byteSource.openBufferedStream();
            properties.load(inputStream);
        } catch (final IOException ioException) {
            ioException.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (final IOException ioException) {
                    throw ioException;
                }
            }
        }
        return properties;
    }
1262444
public static URI getURI(String classpathOrFilePath) {
        return Optional.ofNullable(getResourceURI(classpathOrFilePath))
                .orElseGet(() -> new File(classpathOrFilePath).toURI());
    }
299573
public static String classpathFromClass(Class<?> clazz) {
        String aname = clazz.getPackage().getName().replaceAll("\\.", "/") + "/" +  clazz.getSimpleName()+".class";
        String apath = ClassLoader.getSystemClassLoader().getResource( aname).getPath();
        String path = null;
        if (apath.contains("!")) {
            path = apath.substring(0, apath.indexOf("!")).replace("file:", "");
        } else {
            path = apath.substring(0, apath.indexOf(aname));
        }
        return path;
    }
248565
public static <T> T withClasspathOrFilePath(
            String resourceClasspathOrFilePath,
            TypeReference<T> typeReference) {
        return withJsonString(JMResources.getStringWithClasspathOrFilePath(
                resourceClasspathOrFilePath), typeReference);
    }
865563
public static BufferedReader getReader(String path, String charsetName) throws IORuntimeException {
		return getReader(file(path), charsetName);
	}
894311
public static String pathEncode(String path, Charset charset) {
    return encodeReserved(path, FragmentType.PATH_SEGMENT, charset);

    /*
     * path encoding is not equivalent to query encoding, there are few differences, namely dealing
     * with spaces, !, ', (, ), and ~ characters. we will need to manually process those values.
     */
    // return encoded.replaceAll("\\+", "%20");
  }
82011
public void addClassPath(String classpath)
  {
    char sep = CauchoUtil.getPathSeparatorChar();
    int head = 0;
    int tail = 0;
    while (head < classpath.length()) {
      tail = classpath.indexOf(sep, head);

      String segment = null;
      if (tail < 0) {
        segment = classpath.substring(head);
        head = classpath.length();
      }
      else {
        segment = classpath.substring(head, tail);
        head = tail + 1;
      }

      if (segment.equals(""))
        continue;
      else if (segment.endsWith(".jar") || segment.endsWith(".zip"))
        addMergePath(JarPath.create(VfsOld.lookup(segment)));
      else
        addMergePath(VfsOld.lookup(segment));
    }
  }
210885
public static String classFilePathToClassname(String relativePath)
    {
        if (relativePath == null)
            return null;

        final int pos = relativePath.lastIndexOf(".class");
        if (pos < 0 && relativePath.lastIndexOf(".java") < 0)
            throw new IllegalArgumentException("Not a .class/.java file path: " + relativePath);

        relativePath = FilenameUtils.separatorsToUnix(relativePath);

        if (relativePath.startsWith("/"))
        {
            relativePath = relativePath.substring(1);
        }

        if (relativePath.startsWith("src/main/java/"))
        {
            relativePath = relativePath.substring("src/main/java/".length());
        }

        if (relativePath.startsWith("WEB-INF/classes/"))
        {
            relativePath = relativePath.substring("WEB-INF/classes/".length());
        }

        if (relativePath.startsWith("WEB-INF/classes.jdk15/"))
        {
            relativePath = relativePath.substring("WEB-INF/classes.jdk15/".length());
        }

        if (relativePath.endsWith(".class"))
        {
            relativePath = relativePath.substring(0, relativePath.length() - ".class".length());
        }
        else if (relativePath.endsWith(".java"))
        {
            relativePath = relativePath.substring(0, relativePath.length() - ".java".length());
        }

        String qualifiedName = relativePath.replace("/", ".");
        return qualifiedName;
    }
1114857
public static String convertClassNameToResourcePath(String className) {
        Assert.notNull(className, "Class name must not be null");
        return className.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
    }
955158
private String getClassNameFromPath(String path) {
        String className = path.replace(".class", "");

        // for *nix
        if (className.startsWith("/")) {
            className = className.substring(1, className.length());
        }
        className = className.replace("/", ".");

        // for windows
        if (className.startsWith("\\")) {
            className = className.substring(1, className.length());
        }
        className = className.replace("\\", ".");

        return className;
    }
680907
public String convertToPath(String className) {
        final String fixedDir = destDirName.endsWith(File.separator) ? destDirName: destDirName + File.separator;
        final String fixedClassName = className.replace('.', '/');
        return fixedDir + fixedClassName + ".java";
    }