當前位置: 首頁>>代碼示例>>Java>>正文


Java File.isHidden方法代碼示例

本文整理匯總了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;
 }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:18,代碼來源:Util.java

示例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);
        }
      }
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:JarFinder.java

示例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);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:12,代碼來源:ExtensionFileFilter.java

示例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;
}
 
開發者ID:ajtdnyy,項目名稱:PackagePlugin,代碼行數:47,代碼來源:FileUtil.java

示例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);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:38,代碼來源:UpgradeDownloadTask.java

示例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);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:32,代碼來源:SimpleFolder.java

示例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();
}
 
開發者ID:tedyli,項目名稱:Tedyli-Searcher,代碼行數:10,代碼來源:Indexer.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:28,代碼來源:LocalBackend.java

示例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;
}
 
開發者ID:juliango202,項目名稱:jijimaku,代碼行數:35,代碼來源:WorkerAnnotate.java

示例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;
    }
 
開發者ID:noti0na1,項目名稱:HFSN,代碼行數:35,代碼來源:Pages.java

示例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;
}
 
開發者ID:matthieu-labas,項目名稱:JRF,代碼行數:15,代碼來源:FileInfos.java

示例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);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:38,代碼來源:ListDirStep.java

示例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();
        }
    };
}
 
開發者ID:dream-lab,項目名稱:echo,代碼行數:55,代碼來源:GetFileFromAttribute.java

示例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); 
    }
 
開發者ID:SnailFastGo,項目名稱:netty_op,代碼行數:50,代碼來源:NettyHttpFileServerHandler.java

示例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;
}
 
開發者ID:monkeyWie,項目名稱:proxyee-down,代碼行數:43,代碼來源:HttpDownController.java


注:本文中的java.io.File.isHidden方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。