本文整理汇总了Java中java.io.File.isHidden方法的典型用法代码示例。如果您正苦于以下问题:Java File.isHidden方法的具体用法?Java File.isHidden怎么用?Java File.isHidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.File
的用法示例。
在下文中一共展示了File.isHidden方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GetFileInfo
import java.io.File; //导入方法依赖的package包/类
public static FileInfo GetFileInfo(String filePath)
{
File lFile = new File(filePath);
if (!lFile.exists())
return null;
FileInfo lFileInfo = new FileInfo();
lFileInfo.canRead = lFile.canRead();
lFileInfo.canWrite = lFile.canWrite();
lFileInfo.isHidden = lFile.isHidden();
lFileInfo.fileName = Util.getNameFromFilepath(filePath);
lFileInfo.ModifiedDate = lFile.lastModified();
lFileInfo.IsDir = lFile.isDirectory();
lFileInfo.filePath = filePath;
lFileInfo.fileSize = lFile.length();
return lFileInfo;
}
示例2: zipDir
import java.io.File; //导入方法依赖的package包/类
private static void zipDir(File dir, String relativePath, ZipOutputStream zos,
boolean start) throws IOException {
String[] dirList = dir.list();
for (String aDirList : dirList) {
File f = new File(dir, aDirList);
if (!f.isHidden()) {
if (f.isDirectory()) {
if (!start) {
ZipEntry dirEntry = new ZipEntry(relativePath + f.getName() + "/");
zos.putNextEntry(dirEntry);
zos.closeEntry();
}
String filePath = f.getPath();
File file = new File(filePath);
zipDir(file, relativePath + f.getName() + "/", zos, false);
}
else {
String path = relativePath + f.getName();
if (!path.equals(JarFile.MANIFEST_NAME)) {
ZipEntry anEntry = new ZipEntry(path);
copyToZipStream(f, anEntry, zos);
}
}
}
}
}
示例3: accept
import java.io.File; //导入方法依赖的package包/类
public boolean accept(File file) {
if (file.isHidden()) {
return false;
}
if (file.isDirectory()) {
return true;
}
return file.getName().toLowerCase().endsWith(extension);
}
示例4: searchOneFile
import java.io.File; //导入方法依赖的package包/类
/**
* 递归查找单个文件,找到结果就返回
*
* @param rootDirPath 查找起始目录
* @param paths 要查找的文件路径
* @param depth 查找深度
* @return
*/
public static File searchOneFile(String rootDirPath, String[] paths, int depth) {
File rootDir = new File(rootDirPath);
if (!rootDir.exists() || !rootDir.isDirectory()) {
return null;
}
FileTree tree = FILE_TREE.searchByPath(paths);//优先通过缓存数据查找
if (tree != null) {
return new File(tree.getAbsolutePath());
}
File[] listFiles = rootDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return !pathname.isHidden();
}
});
for (File listFile : listFiles) {
if (!listFile.isHidden() && !listFile.getName().endsWith(".java") && !listFile.getName().startsWith(".")) {
FILE_TREE.addChild(listFile);//扫描过的文件存储到多叉树中
}
if (!checkPath(paths, listFile)) {//路径不匹配时跳出当前路径遍历
continue;
}
if (listFile.getName().equals(paths[paths.length - 1])) {
File pFile = listFile.getParentFile();
if (pFile.getName().equals(paths[paths.length - 2]) && pFile.getParentFile().getName().equals(paths[paths.length - 3])) {
return listFile;
}
}
if (listFile.isDirectory() && !listFile.getName().startsWith(".") && !listFile.isHidden() && depth > 0) {
File file = searchOneFile(listFile.getAbsolutePath(), paths, depth--);
if (file != null) {
return file;
}
}
}
return null;
}
示例5: handleDownloadRequest
import java.io.File; //导入方法依赖的package包/类
/**
* Handle the request for downloading upgrade file
*
* @param baseDir:
* the base directory
* @param software:
* work as the sub directory for storing target zip file
* @param target:
* the name of target zip file
*/
private void handleDownloadRequest(String baseDir, String software, String target) {
Path path = Paths.get(baseDir, software, target);
if (log.isTraceEnable()) {
log.info(this, "Downloading " + target);
}
File file = path.toFile();
if (!file.exists() || file.isHidden()) {
sendRspStatus(NOT_FOUND);
return;
}
if (file.isDirectory()) {
sendListing(file);
return;
}
if (!file.isFile()) {
sendRspStatus(FORBIDDEN);
return;
}
httpMsg.putResponseBodyInChunkedFile(file);
}
示例6: ensureLoaded
import java.io.File; //导入方法依赖的package包/类
private void ensureLoaded() throws RepositoryException {
if (data != null && folders != null) {
return;
}
data = new ArrayList<DataEntry>();
folders = new ArrayList<Folder>();
File fileFolder = getFile();
if (fileFolder != null && fileFolder.exists()) {
File[] listFiles = fileFolder.listFiles();
for (File file : listFiles) {
if (file.isHidden()) {
continue;
}
if (file.isDirectory()) {
folders.add(new SimpleFolder(file.getName(), this, getRepository()));
} else if (file.getName().endsWith(".ioo")) {
data.add(new SimpleIOObjectEntry(file.getName().substring(0, file.getName().length() - 4), this,
getRepository()));
} else if (file.getName().endsWith(".rmp")) {
data.add(new SimpleProcessEntry(file.getName().substring(0, file.getName().length() - 4), this,
getRepository()));
} else if (file.getName().endsWith(".blob")) {
data.add(new SimpleBlobEntry(file.getName().substring(0, file.getName().length() - 5), this,
getRepository()));
}
}
Collections.sort(data, NAME_COMPARATOR);
Collections.sort(folders, NAME_COMPARATOR);
}
}
示例7: createIndex
import java.io.File; //导入方法依赖的package包/类
public int createIndex(String dataDirPath, FileFilter filter) throws IOException {
File[] files = new File(dataDirPath).listFiles();
for (File file : files) {
if (!file.isDirectory() && !file.isHidden() && file.exists() && file.canRead() && filter.accept(file)) {
indexFile(file);
}
}
return writer.numDocs();
}
示例8: listFiles
import java.io.File; //导入方法依赖的package包/类
@Override
public List<FileInfo> listFiles(String directory)
{
FileFilter filter = new FileFilter()
{
@Override
public boolean accept(File pathname)
{
return !pathname.isHidden();
}
};
List<FileInfo> results = new ArrayList<FileInfo>();
for( File file : getActualFile(directory).listFiles(filter) )
{
FileInfo info = new FileInfo();
info.setPath(directory);
info.setName(file.getName());
info.setDirectory(file.isDirectory());
info.setSize(file.length());
info.setLastModified(file.lastModified());
info.setMarkAsAttachment(markedAsResources.contains(info.getFullPath()));
results.add(info);
}
return results;
}
示例9: processFile
import java.io.File; //导入方法依赖的package包/类
/**
* Process one file.
* @return if the file was annotated, false otherwise.
*/
private boolean processFile(File fileEntry) throws IOException, FatalParsingException {
String fileContents = FileManager.fileAnyEncodingToString(fileEntry);
if (fileEntry.isHidden() || SubtitleFile.isJijimakuFile(fileContents)) {
LOGGER.debug("{} is one of our annotated subtitle, skip it.", fileEntry.getName());
return false;
}
String fileName = fileEntry.getName();
String fileBaseName = FilenameUtils.getBaseName(fileName);
LOGGER.info("Processing " + fileName + "...");
String[] annotated = annotationService.annotateSubtitleFile(fileName, fileContents);
if (annotated == null) {
LOGGER.info("Nothing to annotate was found in this file(wrong language?)");
return false;
}
// For ASS files, make a copy because the original file will be overwritten
if (FilenameUtils.getExtension(fileName).equals("ass")) {
if (fileBaseName.endsWith(ASS_FILE_BACKUP_SUFFIX)) {
// This is already our copy, just remove suffix when writing out the result
fileBaseName = fileBaseName.substring(0, fileBaseName.lastIndexOf(ASS_FILE_BACKUP_SUFFIX));
} else {
Files.copy(Paths.get(fileEntry.toURI()), Paths.get(fileEntry.getParent() + "/" + fileBaseName + ASS_FILE_BACKUP_SUFFIX + ".ass"));
}
}
String outFile = fileEntry.getParent() + "/" + fileBaseName + ".ass";
FileManager.writeStringArrayToFile(outFile, annotated);
return true;
}
示例10: getDirectory
import java.io.File; //导入方法依赖的package包/类
public static StringBuilder getDirectory(File dir) {
String dirPath = dir.getPath();
StringBuilder buf = new StringBuilder()
.append("<!DOCTYPE html>\r\n")
.append("<html><head><title>")
.append("Listing of: ")
.append(dirPath)
.append("</title></head><body>\r\n")
.append("<h3>\t Listing of: ")
.append(dirPath)
.append("</h3>\r\n")
.append("<hr />\r\n")
.append("<ul>\r\n")
.append("<li><a href=\"../\">..</a></li>\r\n");
//String fileCode = SystemPropertyUtil.get("file.encoding");
for (File f : dir.listFiles()) {
if (f.isHidden() || !f.canRead()) {
continue;
}
//String name = new String(f.getName().getBytes(), fileCode);
String name = f.getName();
// if (!ALLOWED_FILE_NAME.matcher(name).matches()) {
// continue;
// }
// System.out.println(name);
buf.append("<li><a href=\"")
.append(name)
.append("\">")
.append(name)
.append("</a></li>\r\n");
}
buf.append("</ul>\r\n</body></html>\r\n");
return buf;
}
示例11: FileInfos
import java.io.File; //导入方法依赖的package包/类
public FileInfos(File f) {
name = f.getName();
if (name.isEmpty()) // Happens when 'f' is a root
name = f.getPath();
length = f.length();
lastModified = f.lastModified();
attributes = 0;
if (f.isDirectory()) attributes |= BIT_ISDIRECTORY;
if (f.isFile()) attributes |= BIT_ISFILE;
if (f.isHidden()) attributes |= BIT_ISHIDDEN;
if (f.canRead()) attributes |= BIT_CANREAD;
if (f.canWrite()) attributes |= BIT_CANWRITE;
if (f.canExecute()) attributes |= BIT_CANEXECUTE;
}
示例12: createStepNodeValue
import java.io.File; //导入方法依赖的package包/类
@Override
protected void createStepNodeValue(Document doc, Element stepNode) throws EngineException {
try {
// Command line string
if (evaluated instanceof org.mozilla.javascript.Undefined)
throw new EngineException("Source directory path is empty.");
String path = Engine.theApp.filePropertyManager.getFilepathFromProperty(evaluated.toString(), getProject().getName());
File fDir = new File(path);
File[] files = fDir.listFiles();
if (files == null)
throw new EngineException("Source path \""+path+"\" isn't a directory.");
String fileName, fileLastModified, fileSize;
Element element;
File file;
for (int i = 0 ; i < files.length ; i++) {
file = files[i];
if (file.isFile() && !file.isHidden()) {
fileName = file.getName();
fileSize = String.valueOf(file.length());
fileLastModified = String.valueOf(file.lastModified());
element = doc.createElement("file");
element.appendChild(doc.createTextNode(fileName));
element.setAttribute("lastModified", fileLastModified);
element.setAttribute("size", fileSize);
stepNode.appendChild(element);
}
}
}
catch (Exception e) {
setErrorStatus(true);
Engine.logBeans.warn("An error occured while listing directory.", e);
}
}
示例13: createFileFilter
import java.io.File; //导入方法依赖的package包/类
private FileFilter createFileFilter(final ProcessContext context, String directory) {
final long minSize = context.getProperty(MIN_SIZE).asDataSize(DataUnit.B).longValue();
final Double maxSize = context.getProperty(MAX_SIZE).asDataSize(DataUnit.B);
final long minAge = context.getProperty(MIN_AGE).asTimePeriod(TimeUnit.MILLISECONDS);
final Long maxAge = context.getProperty(MAX_AGE).asTimePeriod(TimeUnit.MILLISECONDS);
final boolean ignoreHidden = context.getProperty(IGNORE_HIDDEN_FILES).asBoolean();
final Pattern filePattern = Pattern.compile(context.getProperty(FILE_FILTER).getValue());
final String indir = directory;
//context.getProperty(DIRECTORY).evaluateAttributeExpressions().getValue();
final boolean recurseDirs = context.getProperty(RECURSE).asBoolean();
final String pathPatternStr = context.getProperty(PATH_FILTER).getValue();
final Pattern pathPattern = (!recurseDirs || pathPatternStr == null) ? null : Pattern.compile(pathPatternStr);
final boolean keepOriginal = context.getProperty(KEEP_SOURCE_FILE).asBoolean();
return new FileFilter() {
@Override
public boolean accept(final File file) {
if (minSize > file.length()) {
return false;
}
if (maxSize != null && maxSize < file.length()) {
return false;
}
final long fileAge = System.currentTimeMillis() - file.lastModified();
if (minAge > fileAge) {
return false;
}
if (maxAge != null && maxAge < fileAge) {
return false;
}
if (ignoreHidden && file.isHidden()) {
return false;
}
if (pathPattern != null) {
Path reldir = Paths.get(indir).relativize(file.toPath()).getParent();
if (reldir != null && !reldir.toString().isEmpty()) {
if (!pathPattern.matcher(reldir.toString()).matches()) {
return false;
}
}
}
//Verify that we have at least read permissions on the file we're considering grabbing
if (!Files.isReadable(file.toPath())) {
return false;
}
//Verify that if we're not keeping original that we have write permissions on the directory the file is in
if (keepOriginal == false && !Files.isWritable(file.toPath().getParent())) {
return false;
}
return filePattern.matcher(file.getName()).matches();
}
};
}
示例14: sendListing
import java.io.File; //导入方法依赖的package包/类
/**
*@description 返回目录结构数据
*@time 创建时间:2017年9月15日下午2:44:41
*@param ctx
*@param dir
*@author dzn
*/
private static void sendListing(ChannelHandlerContext ctx, File dir){
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
// response.headers().set("CONNECT_TYPE", "text/html;charset=UTF-8");
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html;charset=UTF-8");
String dirPath = dir.getPath();
StringBuilder buf = new StringBuilder();
buf.append("<!DOCTYPE html>\r\n");
buf.append("<html><head><title>");
buf.append(dirPath);
buf.append("目录:");
buf.append("</title></head><body>\r\n");
buf.append("<h3>");
buf.append(dirPath).append(" 目录:");
buf.append("</h3>\r\n");
buf.append("<ul>");
buf.append("<li>链接:<a href=\" ../\")..</a>../</li>\r\n");
for (File f : dir.listFiles()) {
if(f.isHidden() || !f.canRead()) {
continue;
}
String name = f.getName();
if (!ALLOWED_FILE_NAME.matcher(name).matches()) {
continue;
}
buf.append("<li>链接:<a href=\"");
buf.append(name);
buf.append("\">");
buf.append(name);
buf.append("</a></li>\r\n");
}
buf.append("</ul></body></html>\r\n");
ByteBuf buffer = Unpooled.copiedBuffer(buf,CharsetUtil.UTF_8);
response.content().writeBytes(buffer);
buffer.release();
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
示例15: getChildDirList
import java.io.File; //导入方法依赖的package包/类
@RequestMapping("/getChildDirList")
public ResultInfo getChildDirList(@RequestParam String model,
@RequestBody(required = false) DirInfo body) {
ResultInfo resultInfo = new ResultInfo();
List<DirInfo> data = new LinkedList<>();
resultInfo.setData(data);
File[] files;
if (body == null || StringUtils.isEmpty(body.getPath())) {
files = File.listRoots();
} else {
File file = new File(body.getPath());
if (file.exists() && file.isDirectory()) {
files = file.listFiles();
} else {
resultInfo.setStatus(ResultStatus.BAD.getCode()).setMsg("路径不存在");
return resultInfo;
}
}
if (files != null && files.length > 0) {
boolean isFileList = "file".equals(model);
for (File tempFile : files) {
if (tempFile.isFile()) {
if (isFileList) {
data.add(new DirInfo(
StringUtils.isEmpty(tempFile.getName()) ? tempFile.getAbsolutePath()
: tempFile.getName(), tempFile.getAbsolutePath(), true));
}
} else if (tempFile.isDirectory() && (tempFile.getParent() == null || !tempFile
.isHidden())) {
DirInfo dirInfo = new DirInfo(
StringUtils.isEmpty(tempFile.getName()) ? tempFile.getAbsolutePath()
: tempFile.getName(), tempFile.getAbsolutePath(),
tempFile.listFiles() == null ? true : Arrays.stream(tempFile.listFiles())
.noneMatch(file ->
file != null && (file.isDirectory() || isFileList) && !file.isHidden()
));
data.add(dirInfo);
}
}
}
return resultInfo;
}