Here you can find the source of isTempCreatedFile(Path filePath)
public static boolean isTempCreatedFile(Path filePath)
//package com.java2s; /**//from ww w . java 2 s . c o m * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ import java.nio.file.Files; import java.nio.file.Path; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final Pattern _tempCreatedFilePattern = Pattern .compile("[0-9A-F]{6,8}\\.tmp"); public static boolean isTempCreatedFile(Path filePath) { String fileName = String.valueOf(filePath.getFileName()); if ((fileName.startsWith("~$") || ((fileName.startsWith("~") || fileName.startsWith("ppt") || fileName.startsWith("pub")) && fileName .endsWith(".tmp"))) && !Files.isDirectory(filePath)) { return true; } Matcher matcher = _tempCreatedFilePattern.matcher(String .valueOf(filePath.getFileName())); if (matcher.matches() && !Files.isDirectory(filePath)) { return true; } return false; } }