给定文件或目录的最后修改时间是否晚于给定时间

@param file 文件或目录
@param timeMillis 做为对比的时间
@return 是否晚于给定时间
187447
public static boolean newerThan(File file, long timeMillis) {
		if (null == file || false == file.exists()) {
			return false;// 不存在的文件一定比任何时间旧
		}
		return file.lastModified() > timeMillis;
	}
14902
static String readFile(String file) {

        try {
            FileReader     reader = new FileReader(file);
            BufferedReader read   = new BufferedReader(reader);
            StringBuffer   b      = new StringBuffer();
            String         s      = null;
            int            count  = 0;

            while ((s = read.readLine()) != null) {
                count++;

                b.append(s);
                b.append('\n');
            }

            read.close();
            reader.close();

            return b.toString();
        } catch (IOException e) {
            return e.getMessage();
        }
    }
135853
public static String getMediaTypeFromFile(final File file) {
    if (file == null) {
      return null;
    }

    final String fileName = file.getName();
    final int i = fileName.lastIndexOf('.');

    if (i == -1) {
      return null;
    }

    return MEDIA_TYPES.get(fileName.substring(i).toLowerCase());
  }
106853
protected function _timestampFile($file, $time)
    {
        if (!$time) {
            return $file;
        }
        $pos = strrpos($file, '.');
        $name = substr($file, 0, $pos);
        $ext = substr($file, $pos);
        return $name . '.v' . $time . $ext;
    }
1301840
public boolean filterDirectory(File file)
    {
        boolean bProcessFile = super.filterDirectory(file);
        if (bProcessFile == false)
            return bProcessFile;
        String strName = file.getName();
        for (String strMonth : m_rgstrMonths)
        {
            if (strName.equalsIgnoreCase(strMonth))
                return false;
        }
        if (Utility.isNumeric(strName))
        {
            int iYear = Integer.parseInt(strName);
            if ((iYear > 1990) && (iYear < 2020))
                return false;
        }
        return bProcessFile;
    }
1050731
public static long size(File file) {
		Assert.notNull(file, "file argument is null !");
		if (false == file.exists()) {
			throw new IllegalArgumentException(StrUtil.format("File [{}] not exist !", file.getAbsolutePath()));
		}

		if (file.isDirectory()) {
			long size = 0L;
			File[] subFiles = file.listFiles();
			if (ArrayUtil.isEmpty(subFiles)) {
				return 0L;// empty directory
			}
			for (int i = 0; i < subFiles.length; i++) {
				size += size(subFiles[i]);
			}
			return size;
		} else {
			return file.length();
		}
	}
63376
public JavaFileObject asJavaFileObject(File file) {
        JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
        return fm.getRegularFile(file);
    }
271203
public static final long timeFromIntentInMillis(Intent intent) {
        // If the time was specified, then use that. Otherwise, use the current
        // time.
        Uri data = intent.getData();
        long millis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
        if (millis == -1 && data != null && data.isHierarchical()) {
            List<String> path = data.getPathSegments();
            if (path.size() == 2 && path.get(0).equals("time")) {
                try {
                    millis = Long.valueOf(data.getLastPathSegment());
                } catch (NumberFormatException e) {
                    Log.i("Calendar", "timeFromIntentInMillis: Data existed but no valid time "
                            + "found. Using current time.");
                }
            }
        }
        if (millis <= 0) {
            millis = System.currentTimeMillis();
        }
        return millis;
    }
475484
private static void watchFile(final File file, ResourceLoader resourceLoader, String resourcePaths) {
        LOGGER.info("监控文件："+file.toString());
        DirectoryWatcher.WatcherCallback watcherCallback = new DirectoryWatcher.WatcherCallback(){
            private long lastExecute = System.currentTimeMillis();
            @Override
            public void execute(WatchEvent.Kind<?> kind, String path) {
                if(System.currentTimeMillis() - lastExecute > 1000){
                    lastExecute = System.currentTimeMillis();
                    if(!path.equals(file.toString())){
                        return;
                    }
                    LOGGER.info("事件："+kind.name()+" ,路径："+path);
                    synchronized(AutoDetector.class){
                        DirectoryWatcher dw = WATCHER_CALLBACKS.get(this);
                        String paths = RESOURCES.get(dw);
                        ResourceLoader loader = RESOURCE_LOADERS.get(dw);
                        LOGGER.info("重新加载数据");
                        loadAndWatch(loader, paths);
                    }
                }
            }

        };
        DirectoryWatcher fileWatcher = DirectoryWatcher.getDirectoryWatcher(watcherCallback,
                StandardWatchEventKinds.ENTRY_MODIFY,
                    StandardWatchEventKinds.ENTRY_DELETE);
        fileWatcher.watchDirectory(file.getParent());
        WATCHER_CALLBACKS.put(watcherCallback, fileWatcher);
        RESOURCES.put(fileWatcher, resourcePaths);
        RESOURCE_LOADERS.put(fileWatcher, resourceLoader);
    }
682859
public static File noDirectory(File file) {
		Validate.exists(file);
		if(file.isDirectory())
			throw new ParameterException("\""+file+"\" is a directory!");
		return file;
	}
1169198
public File getMinifiedFile(File file) {
        File output = getOutputFile(file);
        return new File(output.getParentFile().getAbsoluteFile(),
                output.getName().replace(".js", googleClosureMinifierSuffix + ".js"));
    }
711396
public static void appendEpochMillis(StringBuilder buf, long timeMillis) {
        buf.append(dateTimeFormatter.format(Instant.ofEpochMilli(timeMillis)))
           .append('(').append(timeMillis).append(')');
    }
899904
public static WordVectors loadStaticModel(@NonNull File file) {
        if (!file.exists() || file.isDirectory())
            throw new RuntimeException(
                    new FileNotFoundException("File [" + file.getAbsolutePath() + "] was not found"));

        int originalFreq = Nd4j.getMemoryManager().getOccasionalGcFrequency();
        boolean originalPeriodic = Nd4j.getMemoryManager().isPeriodicGcActive();

        if (originalPeriodic)
            Nd4j.getMemoryManager().togglePeriodicGc(false);

        Nd4j.getMemoryManager().setOccasionalGcFrequency(50000);

        CompressedRamStorage<Integer> storage = new CompressedRamStorage.Builder<Integer>().useInplaceCompression(false)
                        .setCompressor(new NoOp()).emulateIsAbsent(false).build();

        VocabCache<VocabWord> vocabCache = new AbstractCache.Builder<VocabWord>().build();


        // now we need to define which file format we have here
        // if zip - that's dl4j format
        try {
            log.debug("Trying DL4j format...");
            File tmpFileSyn0 = DL4JFileUtils.createTempFile("word2vec", "syn");
            tmpFileSyn0.deleteOnExit();

            ZipFile zipFile = new ZipFile(file);
            ZipEntry syn0 = zipFile.getEntry("syn0.txt");
            InputStream stream = zipFile.getInputStream(syn0);

            FileUtils.copyInputStreamToFile(stream, tmpFileSyn0);
            storage.clear();

            try (Reader reader = new CSVReader(tmpFileSyn0)) {
                while (reader.hasNext()) {
                    Pair<VocabWord, float[]> pair = reader.next();
                    VocabWord word = pair.getFirst();
                    storage.store(word.getIndex(), pair.getSecond());

                    vocabCache.addToken(word);
                    vocabCache.addWordToIndex(word.getIndex(), word.getLabel());

                    Nd4j.getMemoryManager().invokeGcOccasionally();
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                if (originalPeriodic)
                    Nd4j.getMemoryManager().togglePeriodicGc(true);

                Nd4j.getMemoryManager().setOccasionalGcFrequency(originalFreq);

                try {
                    tmpFileSyn0.delete();
                } catch (Exception e) {
                    //
                }
            }
        } catch (Exception e) {
            //
            try {
                // try to load file as text csv
                vocabCache = new AbstractCache.Builder<VocabWord>().build();
                storage.clear();
                log.debug("Trying CSVReader...");
                try (Reader reader = new CSVReader(file)) {
                    while (reader.hasNext()) {
                        Pair<VocabWord, float[]> pair = reader.next();
                        VocabWord word = pair.getFirst();
                        storage.store(word.getIndex(), pair.getSecond());

                        vocabCache.addToken(word);
                        vocabCache.addWordToIndex(word.getIndex(), word.getLabel());

                        Nd4j.getMemoryManager().invokeGcOccasionally();
                    }
                } catch (Exception ef) {
                    // we throw away this exception, and trying to load data as binary model
                    throw new RuntimeException(ef);
                } finally {
                    if (originalPeriodic)
                        Nd4j.getMemoryManager().togglePeriodicGc(true);

                    Nd4j.getMemoryManager().setOccasionalGcFrequency(originalFreq);
                }
            } catch (Exception ex) {
                // otherwise it's probably google model. which might be compressed or not
                log.debug("Trying BinaryReader...");
                vocabCache = new AbstractCache.Builder<VocabWord>().build();
                storage.clear();
                try (Reader reader = new BinaryReader(file)) {
                    while (reader.hasNext()) {
                        Pair<VocabWord, float[]> pair = reader.next();
                        VocabWord word = pair.getFirst();

                        storage.store(word.getIndex(), pair.getSecond());

                        vocabCache.addToken(word);
                        vocabCache.addWordToIndex(word.getIndex(), word.getLabel());

                        Nd4j.getMemoryManager().invokeGcOccasionally();
                    }
                } catch (Exception ez) {
                    throw new RuntimeException("Unable to guess input file format");
                } finally {
                    if (originalPeriodic)
                        Nd4j.getMemoryManager().togglePeriodicGc(true);

                    Nd4j.getMemoryManager().setOccasionalGcFrequency(originalFreq);
                }
            } finally {
                if (originalPeriodic)
                    Nd4j.getMemoryManager().togglePeriodicGc(true);

                Nd4j.getMemoryManager().setOccasionalGcFrequency(originalFreq);
            }
        }


        StaticWord2Vec word2Vec = new StaticWord2Vec.Builder(storage, vocabCache).build();

        return word2Vec;
    }
1294425
public final synchronized ExtendedArtifact searchArtifact(File file) {
		final String filename = removePathPrefix(getBaseDirectory(), file);

		getLog().debug("Retreiving module for " + filename); //$NON-NLS-1$

		File theFile = file;
		File pomDirectory = null;
		while (theFile != null && pomDirectory == null) {
			if (theFile.isDirectory()) {
				final File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$
				if (pomFile.exists()) {
					pomDirectory = theFile;
				}
			}
			theFile = theFile.getParentFile();
		}

		if (pomDirectory != null) {
			ExtendedArtifact a = this.localArtifactDescriptions.get(pomDirectory);
			if (a == null) {
				a = readPom(pomDirectory);
				this.localArtifactDescriptions.put(pomDirectory, a);
				getLog().debug("Found local module description for " //$NON-NLS-1$
						+ a.toString());
			}
			return a;
		}

		final BuildContext buildContext = getBuildContext();
		buildContext.addMessage(file,
				1, 1,
				"The maven module for this file cannot be retreived.", //$NON-NLS-1$
				BuildContext.SEVERITY_WARNING, null);
		return null;
	}
1211974
public static File [] listFiles(File file) {
		if (file==null){
			return EMPTY_FILE_LIST;
		} 
		
		File ret[]=file.listFiles(FILE_FILTER);
		
		if (ret==null){
			return EMPTY_FILE_LIST;
		} else {
			return ret;
		}		
	}
559719
public static boolean deleteFile(File file) {
        if (file.exists()) {
            if (file.isDirectory()) {
                try {
                    deleteDirectory(file);
                    return true;
                } catch (IOException e) {
                    logger.error(e.getMessage());
                    return false;
                }
            } else {
                return file.delete();
            }
        }
        return false;
    }
738053
public static boolean deleteDatabase(File file) {
        if (file == null) {
            throw new IllegalArgumentException("file must not be null");
        }

        boolean deleted = false;
        deleted |= file.delete();
        deleted |= new File(file.getPath() + "-journal").delete();
        deleted |= new File(file.getPath() + "-shm").delete();
        deleted |= new File(file.getPath() + "-wal").delete();

        File dir = file.getParentFile();
        if (dir != null) {
            final String prefix = file.getName() + "-mj";
            File[] files = dir.listFiles(new FileFilter() {
                @Override
                public boolean accept(File candidate) {
                    return candidate.getName().startsWith(prefix);
                }
            });
            if (files != null) {
                for (File masterJournal : files) {
                    deleted |= masterJournal.delete();
                }
            }
        }
        return deleted;
    }