// 获得某个文件夹folderPath下面某种文件后缀fileType的所有文件名
	public static List<String> getFileNamesInFolder(String folderPath,
			String fileType) {
		File folder = new File(folderPath);
		File[] files = folder.listFiles();
		List<String> fileNames = new ArrayList<String>();
		for (int i = 0; i < files.length; ++i) {
			File file = files[i];
			if (file.isFile()) {
				String[] str = file.getPath().split("\\.");
				if (str[str.length - 1].equals(fileType)) { // 分割完后查最后的分割单元
					fileNames.add(file.getName().split("\\.")[0]);
				}
			}
		}

		return fileNames;
	}

	// 递归查询当前可以使用的默认文件名Test的number
	public static int calFileNameIndex(List<String> nameList, int currentNum) {
		String str = "Test";

		for (int i = 0; i < nameList.size(); ++i) {
			if (nameList.get(i).toString().equals(str + currentNum)) {
				nameList.remove(i);
				currentNum = calFileNameIndex(nameList, ++currentNum);
				break;
			}
		}
		return currentNum;
	}

  

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2021-12-26
  • 2021-08-09
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-13
  • 2021-05-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-01-23
  • 2021-10-08
相关资源
相似解决方案