本文整理汇总了Java中java.nio.file.Path.endsWith方法的典型用法代码示例。如果您正苦于以下问题:Java Path.endsWith方法的具体用法?Java Path.endsWith怎么用?Java Path.endsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.Path
的用法示例。
在下文中一共展示了Path.endsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canContainBannedWord
import java.nio.file.Path; //导入方法依赖的package包/类
private static boolean canContainBannedWord(Path path) {
final String[] whiteList;
switch (MODE) {
case XSEMANTICS:
whiteList = XSEMANTICS_BANNED_WORDS_WHITELIST;
break;
case Xpect:
whiteList = Xpect_BANNED_WORDS_WHITELIST;
break;
default:
whiteList = BANNED_WORDS_WHITELIST;
}
for (String whitelisted : whiteList) {
if (path.endsWith(whitelisted)) {
return true;
}
}
return false;
}
示例2: setWatcherOnThemeFile
import java.nio.file.Path; //导入方法依赖的package包/类
private static void setWatcherOnThemeFile() {
try {
WatchService watchService = FileSystems.getDefault().newWatchService();
WatchKey watchKey = path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
while (true) {
final WatchKey wk = watchService.take();
for (WatchEvent<?> event : wk.pollEvents()) {
//we only register "ENTRY_MODIFY" so the context is always a Path.
final Path changed = (Path) event.context();
System.out.println(changed);
if (changed.endsWith("Theme.css")) {
System.out.println("Theme.css has changed...reloading stylesheet.");
scene.getStylesheets().clear();
scene.getStylesheets().add("resources/Theme.css");
}
}
boolean valid = wk.reset();
if (!valid)
System.out.println("Watch Key has been reset...");
}
} catch (Exception e) { /*Thrown to void*/ }
}
示例3: getJREClasses
import java.nio.file.Path; //导入方法依赖的package包/类
static List<Path> getJREClasses() throws IOException {
List<Path> result = new ArrayList<Path>();
Path home = Paths.get(System.getProperty("java.home"));
if (home.endsWith("jre")) {
// jar files in <javahome>/jre/lib
// skip <javahome>/lib
result.addAll(addJarFiles(home.resolve("lib")));
} else if (home.resolve("lib").toFile().exists()) {
// either a JRE or a jdk build image
File classes = home.resolve("classes").toFile();
if (classes.exists() && classes.isDirectory()) {
// jdk build outputdir
result.add(classes.toPath());
}
// add other JAR files
result.addAll(addJarFiles(home.resolve("lib")));
} else {
throw new RuntimeException("\"" + home + "\" not a JDK home");
}
return result;
}
示例4: isIgnored
import java.nio.file.Path; //导入方法依赖的package包/类
@Override
protected boolean isIgnored(Path path, String pathStr) {
if (path.endsWith("pom.xml"))
return false; // never ignore pom.xml!
if (isFile(pathStr, IGNORED_FILES))
return true; // ignore ignored files
if (isBelowFolder(pathStr, IGNORED_FOLDERS))
return true; // ignore files in ignored folders
if (hasExtension(path, ".prefs"))
return true; // ignore Eclipse preferences
if (hasExtension(path, ".bib"))
return true; // ignore BibTeX files
return false;
}
示例5: checkFolder
import java.nio.file.Path; //导入方法依赖的package包/类
/**
* Invoked for every folder for which {@link #isIgnored(Path, String)} returns <code>false</code>.
*/
@Override
protected void checkFolder(Path path, int depth, Report report) {
if (depth == 0) {
checkFolderRepositoryRoot(path, report);
} else if (depth == DEPTH_OF_PROJECTS && !path.endsWith(".git")) {
checkFolderProjectRoot(path, report);
}
}
示例6: handleEvent
import java.nio.file.Path; //导入方法依赖的package包/类
public void handleEvent ( final Path watchable, final WatchEvent<?> event ) throws IOException
{
final Path path = (Path)event.context ();
logger.debug ( "Change {} for base: {} on {}", new Object[] { event.kind (), watchable, path } );
if ( watchable.endsWith ( "native" ) && path.toString ().equals ( "settings.xml" ) )
{
if ( event.kind () != StandardWatchEventKinds.ENTRY_DELETE )
{
check ();
}
else
{
storageRemoved ();
}
}
else
{
if ( path.toString ().equals ( "settings.xml" ) )
{
if ( event.kind () == StandardWatchEventKinds.ENTRY_CREATE )
{
this.nativeKey = new File ( watchable.toFile (), "native" ).toPath ().register ( this.watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE );
}
}
else if ( path.toString ().endsWith ( ".hds" ) )
{
if ( this.id != null )
{
this.storageManager.fileChanged ( this.path.toFile (), this.id, path.toFile () );
}
}
}
}
示例7: sendImgMsgByUid
import java.nio.file.Path; //导入方法依赖的package包/类
public boolean sendImgMsgByUid(Path imagePath, String uid) {
try {
String mid = uploadMedia(imagePath, true);
if (StringUtils.isBlank(mid)) {
return false;
}
String url = baseUrl + "/webwxsendmsgimg?fun=async&f=json";
Map<String, Object> msg = new HashMap<>();
msg.put("Type", 3);
msg.put("MediaId", mid);
msg.put("FromUserName", myAccount.get("UserName").toString());
msg.put("ToUserName", uid);
msg.put("LocalID", new Date().getTime());
msg.put("ClientMsgId", new Date().getTime());
if (imagePath.endsWith("gif")) {
url = baseUrl + "/webwxsendemoticon?fun=sys";
msg.put("Type", 47);
msg.put("EmojiFlag", 2);
}
Map<String, Object> data = new HashMap<>();
data.put("BaseRequest", baseRequest);
data.put("Msg", msg);
String response = NetUtils.requestWithJson(url, mapper.writeValueAsString(data));
log.debug("response: " + response);
Map res = mapper.readValue(response, Map.class);
if ((int) ((Map) res.get("BaseResponse")).get("Ret") == 0) {
return true;
} else {
return false;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
示例8: visitFile
import java.nio.file.Path; //导入方法依赖的package包/类
@Override
public FileVisitResult visitFile(Path file1, BasicFileAttributes attrs)
throws IOException
{
if (file1.endsWith(PROJECT_FILE_NAME )){
return FileVisitResult.CONTINUE;
}
File file2 = new File(pathToCompareTo.toFile(),pathToBeCompared.relativize(file1).toString());
if (!file2.exists() || file2.isDirectory() ||
!Arrays.equals(Files.readAllBytes(file1), Files.readAllBytes(file2.toPath()))){
differs.set(true);
}
return FileVisitResult.CONTINUE;
}
示例9: init
import java.nio.file.Path; //导入方法依赖的package包/类
private static List<Archive> init() {
List<Archive> result = new ArrayList<>();
Path home = Paths.get(System.getProperty("java.home"));
try {
if (home.endsWith("jre")) {
// jar files in <javahome>/jre/lib
result.addAll(addJarFiles(home.resolve("lib")));
if (home.getParent() != null) {
// add tools.jar and other JDK jar files
Path lib = home.getParent().resolve("lib");
if (Files.exists(lib)) {
result.addAll(addJarFiles(lib));
}
}
} else if (Files.exists(home.resolve("lib"))) {
// either a JRE or a jdk build image
Path classes = home.resolve("classes");
if (Files.isDirectory(classes)) {
// jdk build outputdir
result.add(new JDKArchive(classes));
}
// add other JAR files
result.addAll(addJarFiles(home.resolve("lib")));
} else {
throw new RuntimeException("\"" + home + "\" not a JDK home");
}
return result;
} catch (IOException e) {
throw new Error(e);
}
}
示例10: verifySymLinks
import java.nio.file.Path; //导入方法依赖的package包/类
private void verifySymLinks(String bindir) throws IOException {
File binDir = new File(bindir);
System.err.println("verifying links in: " + bindir);
File isaDir = new File(binDir, getArch()).getAbsoluteFile();
if (!isaDir.exists()) {
throw new RuntimeException("dir: " + isaDir + " does not exist");
}
try (DirectoryStream<Path> ds = Files.newDirectoryStream(binDir.toPath())) {
for (Path p : ds) {
if (symlinkExcludes.matcher(p.toString()).matches() ||
Files.isDirectory(p, NOFOLLOW_LINKS)) {
continue;
}
Path link = new File(isaDir, p.getFileName().toString()).toPath();
if (Files.isSymbolicLink(link)) {
Path target = Files.readSymbolicLink(link);
if (target.startsWith("..") && p.endsWith(target.getFileName())) {
// System.out.println(target + " OK");
continue;
}
System.err.println("target:" + target);
System.err.println("file:" + p);
}
throw new RuntimeException("could not find link to " + p);
}
}
}
示例11: findTestDir
import java.nio.file.Path; //导入方法依赖的package包/类
String findTestDir(String dir) throws IOException {
Path path = Paths.get(dir).toAbsolutePath();
while (path != null && !path.endsWith("test")) {
path = path.getParent();
}
if (path == null) {
throw new IllegalArgumentException(dir + " is not in a test directory");
}
if (!Files.isDirectory(path)) {
throw new IOException(path.toString() + " is not a directory");
}
return path.toString();
}
示例12: IsPathEndsWithList
import java.nio.file.Path; //导入方法依赖的package包/类
private static boolean IsPathEndsWithList(Path path,String[] names){
for(String name: names){
if (path.endsWith(name))
return true;
}
return false;
}
示例13: checkFile
import java.nio.file.Path; //导入方法依赖的package包/类
/**
* Invoked for every file for which {@link #isIgnored(Path, String)} returns <code>false</code>.
*/
@Override
protected void checkFile(Path path, String content, boolean isRegisteredAsThirdParty, Report report) {
if (!isRegisteredAsThirdParty) {
if (path.endsWith(FILE_NAME__PLUGIN_PROPERTIES) || path.endsWith(FILE_NAME__FEATURE_PROPERTIES)) {
checkFilePluginOrFeatureProperties(path, content, report);
} else if (path.endsWith(FILE_NAME__MANIFEST_MF)) {
checkFileManifestMF(path, content, report);
} else if (path.endsWith(FILE_NAME__FEATURE_XML)) {
checkFileFeatureXML(path, content, report);
}
}
String[] moreCRHs = { ".xml", ".html", ".sh", ".tex", ".grammar", "adoc", "n4ts", "n4js", "n4jsx", "n4mf",
"n4jsd", "xt_IN_FOLDER_my", "xt_", "xt_IN_FOLDER_P", "xt_IN_FOLDER_p", "xt.DISABLED", ".idx", ".js",
".ant", ".css", ".txt", ".mwe2txt", ".oldxsem", ".md", ".xtypes", ".xcoretxt", ".yml", ".fjcached",
".xpt", ".def" };
if (hasExtension(path, concat(FILE_EXTENSIONS, moreCRHs))) {
if (hasCorrectCopyrightHeader(path, content)) {
report.setToHasCRH();
} else {
if (path.toString().endsWith(".mwe2")) {
// fixCopyrightHeader(path, content);
}
}
}
if (hasExtension(path, ".xml")) { // FIXME apply ordinary checks to .xml files (by removing this special case)
// special case: .xml files
if (!hasCorrectCopyrightHeader(path, content)) {
report.problems.add("does not contain correct copyright header");
} else {
// report.setToHasCRH();
}
} else if (hasExtension(path, BANNED_EXTENSIONS)) {
// special case: banned file extensions
if (!isRegisteredAsThirdParty) {
report.problems.add("file has a banned file extension (add to third-party.txt or to IGNORED_FILES)");
}
} else {
if (hasExtension(path, FILE_EXTENSIONS)) {
// checks for files with one of the extensions in FILE_EXTENSIONS
checkCommonFiles(path, content, isRegisteredAsThirdParty, report);
}
// checks for all files
if (!isRegisteredAsThirdParty && !inN4Repo(path) && !canContainBannedWord(path)) {
final String bannedWord = containsBannedWord(path, content);
if (bannedWord != null) {
report.problems.add("must not contain banned word '" + bannedWord + "'");
}
}
}
}
示例14: readMcp
import java.nio.file.Path; //导入方法依赖的package包/类
public static void readMcp(Path dir, IMappingAcceptor mappingAcceptor) throws IOException {
Path fieldsCsv = dir.resolve("fields.csv");
if (!Files.isRegularFile(fieldsCsv)) throw new FileNotFoundException("no fields.csv");
Path methodsCsv = dir.resolve("methods.csv");
if (!Files.isRegularFile(fieldsCsv)) throw new FileNotFoundException("no methods.csv");
Path paramsCsv = dir.resolve("params.csv");
if (!Files.isRegularFile(fieldsCsv)) throw new FileNotFoundException("no params.csv");
Path notchSrgSrg = null;
Path excFile = null;
for (Path p : Files.newDirectoryStream(dir, Files::isDirectory)) {
if (!p.endsWith("srgs")) p = p.resolve("srgs");
Path cSrgFile = p.resolve("notch-srg.srg"); // alternatively joined.srg
if (Files.isRegularFile(cSrgFile)) {
if (notchSrgSrg != null) System.err.print("non-unique srg folders: "+notchSrgSrg+", "+cSrgFile);
notchSrgSrg = cSrgFile;
excFile = p.resolve("srg.exc"); // alternatively joined.exc
if (!Files.isRegularFile(excFile)) excFile = null;
}
}
if (notchSrgSrg == null) throw new FileNotFoundException("no notch-srg.srg");
Map<String, String> fieldNames = new HashMap<>();
Map<String, String> fieldComments = new HashMap<>();
readMcpCsv(fieldsCsv, fieldNames, fieldComments);
Map<String, String> methodNames = new HashMap<>();
Map<String, String> methodComments = new HashMap<>();
readMcpCsv(methodsCsv, methodNames, methodComments);
Map<String, String> paramNames = new HashMap<>();
readMcpCsv(paramsCsv, paramNames, null);
Map<String, Integer> maxMethodParamMap = new HashMap<>();
for (String name : paramNames.keySet()) {
int sepPos;
if (!name.startsWith("p_")
|| name.charAt(name.length() - 1) != '_'
|| (sepPos = name.indexOf('_', 3)) == -1
|| sepPos == name.length() - 1) {
throw new IOException("invalid param name: "+name);
}
String key = name.substring(2, sepPos);
int idx = Integer.parseInt(name.substring(sepPos + 1, name.length() - 1));
Integer prev = maxMethodParamMap.get(key);
if (prev == null || prev < idx) {
maxMethodParamMap.put(key, idx);
}
}
Map<String, String> clsReverseMap = excFile != null ? new HashMap<>() : null;
readSrg(notchSrgSrg, methodNames, methodComments, fieldNames, fieldComments, paramNames, maxMethodParamMap, clsReverseMap, mappingAcceptor);
if (excFile != null) {
// read constructor parameter mappings
readMcpExc(excFile, clsReverseMap, paramNames, mappingAcceptor);
}
}
示例15: addFile
import java.nio.file.Path; //导入方法依赖的package包/类
public void addFile(Path file, boolean warn) {
if (contains(file)) {
// discard duplicates
return;
}
if (!fsInfo.exists(file)) {
/* No such file or directory exists */
if (warn) {
log.warning(Lint.LintCategory.PATH,
Warnings.PathElementNotFound(file));
}
super.add(file);
return;
}
Path canonFile = fsInfo.getCanonicalFile(file);
if (canonicalValues.contains(canonFile)) {
/* Discard duplicates and avoid infinite recursion */
return;
}
if (fsInfo.isFile(file)) {
/* File is an ordinary file. */
if ( !file.getFileName().toString().endsWith(".jmod")
&& !file.endsWith("modules")) {
if (!isArchive(file)) {
/* Not a recognized extension; open it to see if
it looks like a valid zip file. */
try {
FileSystems.newFileSystem(file, null).close();
if (warn) {
log.warning(Lint.LintCategory.PATH,
Warnings.UnexpectedArchiveFile(file));
}
} catch (IOException | ProviderNotFoundException e) {
// FIXME: include e.getLocalizedMessage in warning
if (warn) {
log.warning(Lint.LintCategory.PATH,
Warnings.InvalidArchiveFile(file));
}
return;
}
} else {
if (fsInfo.getJarFSProvider() == null) {
log.error(Errors.NoZipfsForArchive(file));
return ;
}
}
}
}
/* Now what we have left is either a directory or a file name
conforming to archive naming convention */
super.add(file);
canonicalValues.add(canonFile);
if (expandJarClassPaths && fsInfo.isFile(file) && !file.endsWith("modules")) {
addJarClassPath(file, warn);
}
}