1 /* 2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 package com.sk.ts.utils; 16 17 import java.util.regex.Pattern; 18 19 /** 20 * 文本文件工具 21 * 22 * @author: xudong 23 * @see: file utils 24 * @version: v1.0.0 25 * @since 2022-02-21 26 */ 27 public class FileUtil { 28 /** 29 * 获取换行符 30 * 31 * @return 换行符 32 */ getNewline()33 public static String getNewline() { 34 return System.getProperty("line.separator"); 35 } 36 37 /** 38 * 正则匹配所选文件名是否符合规范 39 * 40 * @param fileName 文件名 41 * @return boolean 是否匹配 42 */ patternFileName(String fileName)43 public static boolean patternFileName(String fileName) { 44 String pattern = "(([.a-z_A-Z0-9]+).h)"; 45 return Pattern.matches(pattern, fileName); 46 } 47 48 /** 49 * 正则匹配所选文件名是否符合规范 50 * 51 * @param fileName 文件名 52 * @return boolean 是否匹配 53 */ patternFileNameH(String fileName)54 public static boolean patternFileNameH(String fileName) { 55 String pattern = "([.a-z_A-Z0-9]+).h"; 56 return Pattern.matches(pattern, fileName); 57 } 58 } 59