@Test public void testGetLogFileTime() throws Exception { String absoluteFileName = "/var/log/zxtm/hadoop/cache/2012021005/1/access_log_10_2012021005.zip"; String logFileTime = StaticFileUtils.getLogFileTime(absoluteFileName); Assert.assertEquals(logFileTime, "2012021005"); }
public static String getLogFileTime(String absoluteFileName) { String accountDirectory = absoluteFileName.substring(0, absoluteFileName.lastIndexOf("/")); String logFileTimeDirectory = accountDirectory.substring(0, accountDirectory.lastIndexOf("/")); String logFileTime = logFileTimeDirectory.substring(logFileTimeDirectory.lastIndexOf("/") + 1, logFileTimeDirectory.length()); return logFileTime; }
StaticFileUtils { public static String getLogFileTime(String absoluteFileName) { String accountDirectory = absoluteFileName.substring(0, absoluteFileName.lastIndexOf("/")); String logFileTimeDirectory = accountDirectory.substring(0, accountDirectory.lastIndexOf("/")); String logFileTime = logFileTimeDirectory.substring(logFileTimeDirectory.lastIndexOf("/") + 1, logFileTimeDirectory.length()); return logFileTime; } }
StaticFileUtils { public static String getLogFileTime(String absoluteFileName) { String accountDirectory = absoluteFileName.substring(0, absoluteFileName.lastIndexOf("/")); String logFileTimeDirectory = accountDirectory.substring(0, accountDirectory.lastIndexOf("/")); String logFileTime = logFileTimeDirectory.substring(logFileTimeDirectory.lastIndexOf("/") + 1, logFileTimeDirectory.length()); return logFileTime; }  }
StaticFileUtils { public static String getLogFileTime(String absoluteFileName) { String accountDirectory = absoluteFileName.substring(0, absoluteFileName.lastIndexOf("/")); String logFileTimeDirectory = accountDirectory.substring(0, accountDirectory.lastIndexOf("/")); String logFileTime = logFileTimeDirectory.substring(logFileTimeDirectory.lastIndexOf("/") + 1, logFileTimeDirectory.length()); return logFileTime; }  static synchronized String generateRandomBase(); static String expandUser(String pathIn); static DataOutputStream openDataOutputStreamFile(String fileName); static DataInputStream openDataInputStreamFile(String fileName); static DataOutputStream openDataOutputStreamFile(String fileName, int buffsize); static DataInputStream openDataInputStreamFile(String fileName, int buffsize); static byte[] readFile(File file); static byte[] readFile(String fileName); static void copyStreams(InputStream is, OutputStream os, PrintStream ps, long isSize, int buffsize); static void copyStreams(InputStream is, OutputStream os, PrintStream ps, int buffsize); static OutputStream openOutputFile(String fileName); static OutputStream openOutputFile(String fileName, int buffsize); static InputStream openInputFile(String fileName); static InputStream openInputFile(String fileName, int buffsize); static String getWorkingDirectory(); static List<String> joinPath(List<String> paths); static List<String> splitPathList(String pathName); static String[] splitPath(String pathName); static String joinPath(String firstPart, String secondPart); static String[] joinPath(String[] firstPart, String[] secondPart); static String splitPathToString(List<String> pathComps); static String splitPathToString(String[] splitPath); static String rebaseSplitPath(String srcBase, String srcPath, String dstBase); static String[] rebaseSplitPath(String[] srcBase, String[] srcPath, String[] dstBase); static String[] stripBeginingPath(String[] splitPath, int nTimes); static String directoryNameFromFullPath(String fullFilePath); static String stripDirectoryFromFileName(String fullFilePath); static String pathTail(String path); static String[] stripEndPath(String[] splitPath, int nTimes); static List<String> listDir(String filePath); static byte[] readInputStream(InputStream fis, int buffSize); static byte[] readInputStream(InputStream fis); static long computeCrc(InputStream fis); static void mkParentDir(String filePath); static Properties loadProperties(String propertiesPath); static String sanitizeDir(String dir); static Map<String, List> getLocalCachedFiles(String cacheLocation); static String getLogFileTime(String absoluteFileName); static void deleteLocalFile(String fileName); static void deleteFilesOlderThanNDays(String location, int nDays); static void delete(String location, long purgeTime); static Date getDateFromFileName(String fileName); static String getDateStringFromFileName(String fileName); static String getNewestFile(List<String> fileNames); static String getTotalTimeTaken(String dateStart); static Date getDate(String dateString, DateFormat format); static String getMonthYearFromFileDate(String dateString); static BufferedReader inputStreamToBufferedReader(InputStream is); static Random getRnd(); static boolean isSymLink(String filePath); static void close(Closeable stream); static BufferedReader inputStreamToBufferedReader(InputStream is, int buffSize); static String mergePathString(String... pathArray); static RandomAccessFile openRandomReadFile(String filePath); static long fileSize(String filePath); static void drainInputStream(InputStream is); }
StaticFileUtils { public static String getLogFileTime(String absoluteFileName) { String accountDirectory = absoluteFileName.substring(0, absoluteFileName.lastIndexOf("/")); String logFileTimeDirectory = accountDirectory.substring(0, accountDirectory.lastIndexOf("/")); String logFileTime = logFileTimeDirectory.substring(logFileTimeDirectory.lastIndexOf("/") + 1, logFileTimeDirectory.length()); return logFileTime; }  static synchronized String generateRandomBase(); static String expandUser(String pathIn); static DataOutputStream openDataOutputStreamFile(String fileName); static DataInputStream openDataInputStreamFile(String fileName); static DataOutputStream openDataOutputStreamFile(String fileName, int buffsize); static DataInputStream openDataInputStreamFile(String fileName, int buffsize); static byte[] readFile(File file); static byte[] readFile(String fileName); static void copyStreams(InputStream is, OutputStream os, PrintStream ps, long isSize, int buffsize); static void copyStreams(InputStream is, OutputStream os, PrintStream ps, int buffsize); static OutputStream openOutputFile(String fileName); static OutputStream openOutputFile(String fileName, int buffsize); static InputStream openInputFile(String fileName); static InputStream openInputFile(String fileName, int buffsize); static String getWorkingDirectory(); static List<String> joinPath(List<String> paths); static List<String> splitPathList(String pathName); static String[] splitPath(String pathName); static String joinPath(String firstPart, String secondPart); static String[] joinPath(String[] firstPart, String[] secondPart); static String splitPathToString(List<String> pathComps); static String splitPathToString(String[] splitPath); static String rebaseSplitPath(String srcBase, String srcPath, String dstBase); static String[] rebaseSplitPath(String[] srcBase, String[] srcPath, String[] dstBase); static String[] stripBeginingPath(String[] splitPath, int nTimes); static String directoryNameFromFullPath(String fullFilePath); static String stripDirectoryFromFileName(String fullFilePath); static String pathTail(String path); static String[] stripEndPath(String[] splitPath, int nTimes); static List<String> listDir(String filePath); static byte[] readInputStream(InputStream fis, int buffSize); static byte[] readInputStream(InputStream fis); static long computeCrc(InputStream fis); static void mkParentDir(String filePath); static Properties loadProperties(String propertiesPath); static String sanitizeDir(String dir); static Map<String, List> getLocalCachedFiles(String cacheLocation); static String getLogFileTime(String absoluteFileName); static void deleteLocalFile(String fileName); static void deleteFilesOlderThanNDays(String location, int nDays); static void delete(String location, long purgeTime); static Date getDateFromFileName(String fileName); static String getDateStringFromFileName(String fileName); static String getNewestFile(List<String> fileNames); static String getTotalTimeTaken(String dateStart); static Date getDate(String dateString, DateFormat format); static String getMonthYearFromFileDate(String dateString); static BufferedReader inputStreamToBufferedReader(InputStream is); static Random getRnd(); static boolean isSymLink(String filePath); static void close(Closeable stream); static BufferedReader inputStreamToBufferedReader(InputStream is, int buffSize); static String mergePathString(String... pathArray); static RandomAccessFile openRandomReadFile(String filePath); static long fileSize(String filePath); static void drainInputStream(InputStream is); static DateFormat filedf; static DateFormat jobdf; }