本文整理汇总了Java中java.io.File.pathSeparator方法的典型用法代码示例。如果您正苦于以下问题:Java File.pathSeparator方法的具体用法?Java File.pathSeparator怎么用?Java File.pathSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.File
的用法示例。
在下文中一共展示了File.pathSeparator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSearchPaths
import java.io.File; //导入方法依赖的package包/类
static void testSearchPaths() {
List<String> i, x, iF, xF;
i = x = iF = xF = new ArrayList<>();
SourceLocation dir1 = new SourceLocation(Paths.get("dir1"), i, x);
SourceLocation dir2 = new SourceLocation(Paths.get("dir2"), i, x);
String dir1_PS_dir2 = "dir1" + File.pathSeparator + "dir2";
Options options = Options.parseArgs("--source-path", dir1_PS_dir2);
assertEquals(options.getSourceSearchPaths(), Arrays.asList(dir1, dir2));
options = Options.parseArgs("--module-path", dir1_PS_dir2);
assertEquals(options.getModuleSearchPaths(), Arrays.asList(dir1, dir2));
options = Options.parseArgs("--class-path", dir1_PS_dir2);
assertEquals(options.getClassSearchPath(), Arrays.asList(dir1, dir2));
}
示例2: testRunWithNonExistentEntry
import java.io.File; //导入方法依赖的package包/类
/**
* Run the test with a non-existent file on the upgrade module path.
* It should be silently ignored.
*/
public void testRunWithNonExistentEntry() throws Exception {
String upgrademodulepath
= "DoesNotExit" + File.pathSeparator + UPGRADEDMODS_DIR.toString();
String mid = "test/jdk.test.Main";
int exitValue
= executeTestJava(
"--upgrade-module-path", upgrademodulepath,
"--module-path", MODS_DIR.toString(),
"-m", mid)
.outputTo(System.out)
.errorTo(System.out)
.getExitValue();
assertTrue(exitValue == 0);
}
示例3: getExtDirs
import java.io.File; //导入方法依赖的package包/类
/**
* <p>
* @return the java.ext.dirs property as a list of directory
* </p>
*/
private static File[] getExtDirs() {
String s = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.ext.dirs"));
File[] dirs;
if (s != null) {
StringTokenizer st =
new StringTokenizer(s, File.pathSeparator);
int count = st.countTokens();
debug("getExtDirs count " + count);
dirs = new File[count];
for (int i = 0; i < count; i++) {
dirs[i] = new File(st.nextToken());
debug("getExtDirs dirs["+i+"] "+ dirs[i]);
}
} else {
dirs = new File[0];
debug("getExtDirs dirs " + dirs);
}
debug("getExtDirs dirs.length " + dirs.length);
return dirs;
}
示例4: addPath
import java.io.File; //导入方法依赖的package包/类
private static void addPath(
@NullAllowed final String path,
@NonNull Collection<? super FileObject> collector,
final boolean modulepath) {
if (path != null) {
final StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
while (tok.hasMoreTokens()) {
final String binrootS = tok.nextToken();
final File f = FileUtil.normalizeFile(new File(binrootS));
final Collection<? extends File> toAdd = modulepath ?
collectModules(f) :
Collections.singleton(f);
toAdd.forEach((e) -> {
final URL binroot = FileUtil.urlForArchiveOrDir(f);
if (binroot != null) {
final FileObject[] someRoots = SourceForBinaryQuery.findSourceRoots(binroot).getRoots();
Collections.addAll(collector, someRoots);
}
});
}
}
}
示例5: buildEnvironment
import java.io.File; //导入方法依赖的package包/类
Map<String, String> buildEnvironment(Map<String, String> original) {
Map<String, String> ret = new HashMap<String, String>(original);
ret.putAll(envVariables);
// Find PATH environment variable - on Windows it can be some other
// case and we should use whatever it has.
String pathName = getPathName(original);
// TODO use StringBuilder
String currentPath = ret.get(pathName);
if (currentPath == null) {
currentPath = "";
}
for (File path : paths) {
currentPath = path.getAbsolutePath().replace(" ", "\\ ") //NOI18N
+ File.pathSeparator + currentPath;
}
if (!"".equals(currentPath.trim())) {
ret.put(pathName, currentPath);
}
return ret;
}
示例6: putPath
import java.io.File; //导入方法依赖的package包/类
public static void putPath(File path, String pathName, boolean prepend, Map<String, String> current) {
String currentPath = current.get(pathName);
if (currentPath == null) {
currentPath = "";
}
if (prepend) {
currentPath = path.getAbsolutePath().replace(" ", "\\ ") //NOI18N
+ File.pathSeparator + currentPath;
} else {
currentPath = currentPath + File.pathSeparator
+ path.getAbsolutePath().replace(" ", "\\ "); //NOI18N
}
if (!"".equals(currentPath.trim())) {
current.put(pathName, currentPath);
}
}
示例7: run
import java.io.File; //导入方法依赖的package包/类
void run() throws Exception {
String PS = File.pathSeparator;
writeFile("src1/p/A.java",
"package p; public class A { }");
compile("-d", "classes1", "src1/p/A.java");
writeFile("src2/q/B.java",
"package q; public class B extends p.A { }");
compile("-d", "classes2", "-classpath", "classes1", "src2/q/B.java");
writeFile("src/Test.java",
"/** &0; */ class Test extends q.B { }");
test("src/Test.java", "-sourcepath", "src1" + PS + "src2");
test("src/Test.java", "-classpath", "classes1" + PS + "classes2");
File testJar = createJar();
test("src/Test.java", "-bootclasspath",
testJar + PS + "classes1" + PS + "classes2");
if (errors > 0)
throw new Exception(errors + " errors found");
}
示例8: startCluster
import java.io.File; //导入方法依赖的package包/类
private void startCluster(Configuration conf) throws Exception {
if (System.getProperty("hadoop.log.dir") == null) {
System.setProperty("hadoop.log.dir", "target/test-dir");
}
conf.set("dfs.block.access.token.enable", "false");
conf.set("dfs.permissions", "true");
conf.set("hadoop.security.authentication", "simple");
String cp = conf.get(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
StringUtils.join(",",
YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH))
+ File.pathSeparator + classpathDir;
conf.set(YarnConfiguration.YARN_APPLICATION_CLASSPATH, cp);
dfsCluster = new MiniDFSCluster.Builder(conf).build();
FileSystem fileSystem = dfsCluster.getFileSystem();
fileSystem.mkdirs(new Path("/tmp"));
fileSystem.mkdirs(new Path("/user"));
fileSystem.mkdirs(new Path("/hadoop/mapred/system"));
fileSystem.setPermission(
new Path("/tmp"), FsPermission.valueOf("-rwxrwxrwx"));
fileSystem.setPermission(
new Path("/user"), FsPermission.valueOf("-rwxrwxrwx"));
fileSystem.setPermission(
new Path("/hadoop/mapred/system"), FsPermission.valueOf("-rwx------"));
FileSystem.setDefaultUri(conf, fileSystem.getUri());
mrCluster = MiniMRClientClusterFactory.create(this.getClass(), 1, conf);
// so the minicluster conf is avail to the containers.
Writer writer = new FileWriter(classpathDir + "/core-site.xml");
mrCluster.getConfig().writeXml(writer);
writer.close();
}
示例9: createClassPath
import java.io.File; //导入方法依赖的package包/类
private ClassPath createClassPath(String classpath) {
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
List/*<PathResourceImplementation>*/ list = new ArrayList();
while (tokenizer.hasMoreTokens()) {
String item = tokenizer.nextToken();
File f = FileUtil.normalizeFile(new File(item));
URL url = getRootURL(f);
if (url != null) {
list.add(ClassPathSupport.createResource(url));
}
}
return ClassPathSupport.createClassPath(list);
}
示例10: createImage
import java.io.File; //导入方法依赖的package包/类
private void createImage(Path outputDir, String... modules) throws Throwable {
Path jlink = Paths.get(JAVA_HOME, "bin", "jlink");
String mp = JMODS.toString() + File.pathSeparator + MODS_DIR.toString();
assertTrue(executeProcess(jlink.toString(), "--output", outputDir.toString(),
"--add-modules", Arrays.stream(modules).collect(Collectors.joining(",")),
"--module-path", mp)
.outputTo(System.out)
.errorTo(System.out)
.getExitValue() == 0);
}
示例11: main
import java.io.File; //导入方法依赖的package包/类
public static void main(String[] args)
throws Throwable {
String baseDir = System.getProperty("user.dir") + File.separator;
String javac = JDKToolFinder.getTestJDKTool("javac");
String java = JDKToolFinder.getTestJDKTool("java");
setup(baseDir);
String srcDir = System.getProperty("test.src");
String cp = srcDir + File.separator + "a" + File.pathSeparator
+ srcDir + File.separator + "b.jar" + File.pathSeparator
+ ".";
List<String[]> allCMDs = List.of(
// Compile command
new String[]{
javac, "-cp", cp, "-d", ".",
srcDir + File.separator + TEST_NAME + ".java"
},
// Run test the first time
new String[]{
java, "-cp", cp, TEST_NAME, "1"
},
// Run test the second time
new String[]{
java, "-cp", cp, TEST_NAME, "2"
}
);
for (String[] cmd : allCMDs) {
ProcessTools.executeCommand(cmd)
.outputTo(System.out)
.errorTo(System.out)
.shouldHaveExitValue(0);
}
}
示例12: testWithExplodedPatches
import java.io.File; //导入方法依赖的package包/类
/**
* Run test with ---patch-module and exploded patches
*/
public void testWithExplodedPatches() throws Exception {
// patches1/java.base:patches2/java.base
String basePatches = PATCHES1_DIR.resolve("java.base")
+ File.pathSeparator + PATCHES2_DIR.resolve("java.base");
String dnsPatches = PATCHES1_DIR.resolve("jdk.naming.dns")
+ File.pathSeparator + PATCHES2_DIR.resolve("jdk.naming.dns");
String compilerPatches = PATCHES1_DIR.resolve("jdk.compiler")
+ File.pathSeparator + PATCHES2_DIR.resolve("jdk.compiler");
runTest(basePatches, dnsPatches, compilerPatches);
}
示例13: decode
import java.io.File; //导入方法依赖的package包/类
public static File[] decode(String text) {
ArrayList<File> files = new ArrayList<File>();
StringTokenizer tokenizer = new StringTokenizer(text, File.pathSeparator);
while (tokenizer.hasMoreElements()) {
File file = decodeFile((String) tokenizer.nextElement());
files.add(file);
}
return files.toArray(new File[files.size()]);
}
示例14: commandIsAvailable
import java.io.File; //导入方法依赖的package包/类
/**
* Accepts exact path to a given command. A command may be in
* uneven quotes (both single and double).
*/
public static boolean commandIsAvailable(final String command) {
try {
final String quotedCommand = StringUtils.putIntoDoubleQuotes(command);
final String[] parsed = new CommandLineParser().parse(quotedCommand);
if (parsed.length != 1) return false; // not a single command
final File commmandFile = new File(parsed[0]);
// first try to find given executable file in path if command is not in path
if (!commmandFile.isAbsolute()) {
final String pathVariable = getEnvVariable(isWindows() ? "Path" : "PATH");
final StringTokenizer stPath = new StringTokenizer(pathVariable, File.pathSeparator, false);
while (stPath.hasMoreTokens()) {
String commandToCheck = null;
if (isWindows() && !command.endsWith(EXE_SUFFIX)) {
commandToCheck = command + EXE_SUFFIX;
} else {
commandToCheck = command;
}
final String path = stPath.nextToken();
final File fullPath = new File(path, commandToCheck);
if (fullPath.exists() && fullPath.isFile()) return true;
}
}
if (!commmandFile.exists()) return false;
return commmandFile.isFile();
} catch (CommandLineParserException e) {
return false;
}
}
示例15: errorIfNotSameContent
import java.io.File; //导入方法依赖的package包/类
@Test
public void errorIfNotSameContent() {
if (Files.notExists(MODULE_PATH)) {
// exploded image
return;
}
String dir = "test";
String mpath = MODULE_PATH.toString() + File.pathSeparator +
JMODS_DIR.toString();
List<String> options = Stream.of("--dedup-legal-notices",
"error-if-not-same-content",
"--module-path", mpath,
"--add-modules=m3,m4",
"--output", imageDir(dir))
.collect(Collectors.toList());
StringWriter writer = new StringWriter();
PrintWriter pw = new PrintWriter(writer);
System.out.println("jlink " + options.stream().collect(Collectors.joining(" ")));
int rc = JLINK_TOOL.run(pw, pw,
options.toArray(new String[0]));
assertTrue(rc != 0);
assertTrue(writer.toString().trim()
.matches("Error:.*/m4/legal/m4/test-license .*contain different content"));
}