|
|
|
@ -1,482 +0,0 @@
|
|
|
|
|
//package com.weaver.seconddev.interfaces.swfa.sl;
|
|
|
|
|
//
|
|
|
|
|
///**
|
|
|
|
|
// * FileUtil.java
|
|
|
|
|
// * @Author: Administrator
|
|
|
|
|
// * @CreateDate: 2013-2-27
|
|
|
|
|
// * @Version 1.0
|
|
|
|
|
// * Copyright (C) 2013
|
|
|
|
|
// */
|
|
|
|
|
//import java.io.BufferedReader;
|
|
|
|
|
//import java.io.File;
|
|
|
|
|
//import java.io.FileInputStream;
|
|
|
|
|
//import java.io.FileReader;
|
|
|
|
|
//import java.io.FilenameFilter;
|
|
|
|
|
//import java.io.IOException;
|
|
|
|
|
//import java.text.ParseException;
|
|
|
|
|
//import java.text.SimpleDateFormat;
|
|
|
|
|
//import java.util.Date;
|
|
|
|
|
//import java.util.regex.Matcher;
|
|
|
|
|
//import java.util.regex.Pattern;
|
|
|
|
|
////import org.apache.log4j.Logger;
|
|
|
|
|
//import jcifs.smb.SmbAuthException;
|
|
|
|
|
//import jcifs.smb.SmbFile;
|
|
|
|
|
//import jcifs.smb.SmbFileInputStream;
|
|
|
|
|
//import org.slf4j.Logger;
|
|
|
|
|
//import org.slf4j.LoggerFactory;
|
|
|
|
|
//
|
|
|
|
|
///**
|
|
|
|
|
// * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// */
|
|
|
|
|
//public class FileUtil {
|
|
|
|
|
//
|
|
|
|
|
// private static final org.slf4j.Logger logger_e7cead7a = LoggerFactory.getLogger(FileUtil.class);
|
|
|
|
|
//
|
|
|
|
|
// private FileUtil() {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param fname <20><><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static byte[] readLocalFile(String fname) {
|
|
|
|
|
// try {
|
|
|
|
|
// // File file = new File(fname);
|
|
|
|
|
// // FileInputStream is = new FileInputStream(file);
|
|
|
|
|
// SmbFile smbFile = new SmbFile(fname);
|
|
|
|
|
// SmbFileInputStream is = new SmbFileInputStream(smbFile);
|
|
|
|
|
// byte[] buff = new byte[smbFile.getContentLength()];
|
|
|
|
|
// // byte[] buff = new byte[is.available()];
|
|
|
|
|
// is.read(buff);
|
|
|
|
|
// is.close();
|
|
|
|
|
// return buff;
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// try {
|
|
|
|
|
// File file = new File(fname);
|
|
|
|
|
// FileInputStream is = new FileInputStream(file);
|
|
|
|
|
// byte[] buff = new byte[is.available()];
|
|
|
|
|
// is.read(buff);
|
|
|
|
|
// is.close();
|
|
|
|
|
// return buff;
|
|
|
|
|
// } catch (IOException e1) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param fname <20><><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static byte[] readSharedFile(String host, String user, String password, String fname) {
|
|
|
|
|
// String temp = "";
|
|
|
|
|
// try {
|
|
|
|
|
// temp = fname;
|
|
|
|
|
// if (fname.startsWith("\\\\|/")) {
|
|
|
|
|
// temp = fname.replaceFirst("\\\\|/", "");
|
|
|
|
|
// }
|
|
|
|
|
// temp = temp.replaceAll("\\\\", "/");
|
|
|
|
|
// String fullpath = "smb://" + user + ":" + password + "@" + host + temp;
|
|
|
|
|
// SmbFile smbFile = new SmbFile(fullpath);
|
|
|
|
|
// SmbFileInputStream is = new SmbFileInputStream(smbFile);
|
|
|
|
|
// byte[] buff = new byte[smbFile.getContentLength()];
|
|
|
|
|
// is.read(buff);
|
|
|
|
|
// is.close();
|
|
|
|
|
// return buff;
|
|
|
|
|
// } catch (SmbAuthException e) {
|
|
|
|
|
// try {
|
|
|
|
|
// String localpath = "//" + host + temp;
|
|
|
|
|
// FileInputStream fis = new FileInputStream(new File(localpath));
|
|
|
|
|
// byte[] buff = new byte[fis.available()];
|
|
|
|
|
// fis.read(buff);
|
|
|
|
|
// fis.close();
|
|
|
|
|
// return buff;
|
|
|
|
|
// } catch (IOException e1) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * <20>жϹ<D0B6><CFB9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param fname
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static boolean sharedFileExists(String host, String user, String password, String fname) {
|
|
|
|
|
// boolean flg = false;
|
|
|
|
|
// String temp = "";
|
|
|
|
|
// try {
|
|
|
|
|
// temp = fname;
|
|
|
|
|
// if (fname.startsWith("\\\\|/")) {
|
|
|
|
|
// temp = fname.replaceFirst("\\\\|/", "");
|
|
|
|
|
// }
|
|
|
|
|
// temp = fname.replaceAll("\\\\", "/");
|
|
|
|
|
// String fullpath = "smb://" + user + ":" + password + "@" + host + temp;
|
|
|
|
|
// SmbFile smbFile = new SmbFile(fullpath);
|
|
|
|
|
// flg = smbFile.exists();
|
|
|
|
|
// } catch (SmbAuthException e) {
|
|
|
|
|
// String localpath = "//" + host + temp;
|
|
|
|
|
// File file = new File(localpath);
|
|
|
|
|
// flg = file.exists();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// }
|
|
|
|
|
// return flg;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param path <20><><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// // public static Object[] listFiles(String host, String user, String password, String path) {
|
|
|
|
|
// // String temp = "";
|
|
|
|
|
// // try {
|
|
|
|
|
// // temp = path;
|
|
|
|
|
// // if (path.startsWith("\\\\|/")) {
|
|
|
|
|
// // temp = path.replaceFirst("\\\\|/", "");
|
|
|
|
|
// // }
|
|
|
|
|
// // temp = temp.replaceAll("\\\\", "/");
|
|
|
|
|
// // if (!path.endsWith("/")) {
|
|
|
|
|
// // temp += "/";
|
|
|
|
|
// // }
|
|
|
|
|
// // String fullpath = "smb://" + user + ":" + password + "@" + host + temp;
|
|
|
|
|
// // SmbFile smbFile = new SmbFile(fullpath);
|
|
|
|
|
// // return smbFile.listFiles();
|
|
|
|
|
// // } catch (SmbAuthException e) {
|
|
|
|
|
// // try {
|
|
|
|
|
// // String localpath = "//" + host + temp;
|
|
|
|
|
// //
|
|
|
|
|
// // File file = new File(localpath);
|
|
|
|
|
// // return file.listFiles();
|
|
|
|
|
// // } catch (Exception e1) {
|
|
|
|
|
// // e1.printStackTrace();
|
|
|
|
|
// // return null;
|
|
|
|
|
// // }
|
|
|
|
|
// //
|
|
|
|
|
// //
|
|
|
|
|
// // } catch (IOException e) {
|
|
|
|
|
// // e.printStackTrace();
|
|
|
|
|
// // return null;
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// /**
|
|
|
|
|
// * <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>飨<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ʽ<EFBFBD><CABD>ȡ<EFBFBD><C8A1>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param path <20><><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static SmbFile[] listFilesAsShare(String fullpath) {
|
|
|
|
|
// try {
|
|
|
|
|
// SmbFile smbFile = new SmbFile(fullpath);
|
|
|
|
|
// return smbFile.listFiles();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>飨<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ʽ<EFBFBD><CABD>ȡ<EFBFBD><C8A1>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param path <20><><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static SmbFile[] listFilesAsShare(String host, String user, String password, String path) {
|
|
|
|
|
// try {
|
|
|
|
|
// String temp = path;
|
|
|
|
|
// if (path.startsWith("\\\\|/")) {
|
|
|
|
|
// temp = path.replaceFirst("\\\\|/", "");
|
|
|
|
|
// }
|
|
|
|
|
// temp = temp.replaceAll("\\\\", "/");
|
|
|
|
|
// if (!path.endsWith("/")) {
|
|
|
|
|
// temp += "/";
|
|
|
|
|
// }
|
|
|
|
|
// String fullpath = "smb://" + user + ":" + password + "@" + host + temp;
|
|
|
|
|
// SmbFile smbFile = new SmbFile(fullpath);
|
|
|
|
|
// return smbFile.listFiles();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ʱ<EFBFBD><CAB1>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param path
|
|
|
|
|
// * @param dateFormat <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD>ʽ
|
|
|
|
|
// * <09>磺<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϊ
|
|
|
|
|
// * @param time ָ<><D6B8>ʱ<EFBFBD><CAB1>
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static String searchLatestFiles(String host, String user, String password, String path, String dateFormat, Date time) {
|
|
|
|
|
// String temp = "";
|
|
|
|
|
// final Pattern yPattern = Pattern.compile("\\d{4}");
|
|
|
|
|
// final Pattern ymPattern = Pattern.compile("\\d{6}");
|
|
|
|
|
// final Pattern ymdPattern = Pattern.compile("\\d{8}");
|
|
|
|
|
// final SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
|
|
|
|
// final Date initTime = time;
|
|
|
|
|
// temp = path;
|
|
|
|
|
// if (path.startsWith("\\\\|/")) {
|
|
|
|
|
// temp = path.replaceFirst("\\\\|/", "");
|
|
|
|
|
// }
|
|
|
|
|
// temp = temp.replaceAll("\\\\", "/");
|
|
|
|
|
// if (!temp.endsWith("/")) {
|
|
|
|
|
// temp += "/";
|
|
|
|
|
// }
|
|
|
|
|
// try {
|
|
|
|
|
// String localpath = "//" + host + temp;
|
|
|
|
|
// File file = new File(localpath);
|
|
|
|
|
// File[] fileYearList = file.listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = yPattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (fileYearList != null && fileYearList.length > 0) {
|
|
|
|
|
// for (int i = fileYearList.length - 1; i >= 0; i--) {
|
|
|
|
|
// File[] fileYMList = fileYearList[i].listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = ymPattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (null != fileYMList && fileYMList.length > 0) {
|
|
|
|
|
// for (int j = fileYMList.length - 1; j >= 0; j--) {
|
|
|
|
|
// File[] fileYMDList = fileYMList[j].listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = ymdPattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (null != fileYMDList && fileYMDList.length > 0) {
|
|
|
|
|
// for (int k = fileYMDList.length - 1; k >= 0; k--) {
|
|
|
|
|
// File[] fileList = fileYMDList[k].listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// try {
|
|
|
|
|
// Date curTime = sdf.parse(name);
|
|
|
|
|
// if (curTime.compareTo(initTime) <= 0) {
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ParseException e) {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (null != fileList && fileList.length > 0) {
|
|
|
|
|
// File tempFile = fileList[fileList.length - 1];
|
|
|
|
|
// // TODO
|
|
|
|
|
// int index = tempFile.getAbsolutePath().indexOf(host);
|
|
|
|
|
// return tempFile.getAbsolutePath().substring(index + host.length());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e1) {
|
|
|
|
|
// e1.printStackTrace();
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * @param host
|
|
|
|
|
// * @param user
|
|
|
|
|
// * @param password
|
|
|
|
|
// * @param path
|
|
|
|
|
// * @param p
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// public static String searchLatestFiles(String host, String user, String password, String path, Pattern p) {
|
|
|
|
|
// String temp = "";
|
|
|
|
|
// final Pattern yPattern = Pattern.compile("\\d{4}");
|
|
|
|
|
// final Pattern ymPattern = Pattern.compile("\\d{6}");
|
|
|
|
|
// final Pattern ymdPattern = Pattern.compile("\\d{8}");
|
|
|
|
|
// final Pattern fnamePattern = p;
|
|
|
|
|
// temp = path;
|
|
|
|
|
// if (path.startsWith("\\\\|/")) {
|
|
|
|
|
// temp = path.replaceFirst("\\\\|/", "");
|
|
|
|
|
// }
|
|
|
|
|
// temp = temp.replaceAll("\\\\", "/");
|
|
|
|
|
// if (!temp.endsWith("/")) {
|
|
|
|
|
// temp += "/";
|
|
|
|
|
// }
|
|
|
|
|
// // try {
|
|
|
|
|
// //
|
|
|
|
|
// // String fullpath = "smb://" + user + ":" + password + "@" + host + temp;
|
|
|
|
|
// // SmbFile smbFile = new SmbFile(fullpath);
|
|
|
|
|
// // SmbFile[] smbFileYearList = smbFile.listFiles(new SmbFilenameFilter() {
|
|
|
|
|
// // @Override
|
|
|
|
|
// // public boolean accept(SmbFile dir, String name) {
|
|
|
|
|
// // Matcher m = yPattern.matcher(name);
|
|
|
|
|
// // return m.matches();
|
|
|
|
|
// // }});
|
|
|
|
|
// // if (smbFileYearList != null) {
|
|
|
|
|
// // for (int i = smbFileYearList.length - 1; i >= 0; i--) {
|
|
|
|
|
// // SmbFile[] smbFileYMList = smbFileYearList[i].listFiles(new SmbFilenameFilter() {
|
|
|
|
|
// // @Override
|
|
|
|
|
// // public boolean accept(SmbFile dir, String name) {
|
|
|
|
|
// // Matcher m = ymPattern.matcher(name);
|
|
|
|
|
// // return m.matches();
|
|
|
|
|
// // }});
|
|
|
|
|
// // if (null != smbFileYMList) {
|
|
|
|
|
// // for (int j = smbFileYMList.length - 1; j >= 0; j--) {
|
|
|
|
|
// // SmbFile[] smbFileYMDList = smbFileYMList[j].listFiles(new SmbFilenameFilter() {
|
|
|
|
|
// // @Override
|
|
|
|
|
// // public boolean accept(SmbFile dir, String name) {
|
|
|
|
|
// // Matcher m = ymdPattern.matcher(name);
|
|
|
|
|
// // return m.matches();
|
|
|
|
|
// // }});
|
|
|
|
|
// // if (null != smbFileYMDList) {
|
|
|
|
|
// // for (int k = smbFileYMDList.length - 1; k >= 0; k--) {
|
|
|
|
|
// // SmbFile[] smbFileList = smbFileYMDList[k].listFiles(new SmbFilenameFilter() {
|
|
|
|
|
// // @Override
|
|
|
|
|
// // public boolean accept(SmbFile dir, String name) {
|
|
|
|
|
// // Matcher m = fnamePattern.matcher(name);
|
|
|
|
|
// // return m.matches();
|
|
|
|
|
// // }});
|
|
|
|
|
// // if (null != smbFileList && smbFileList.length > 0) {
|
|
|
|
|
// // SmbFile tempFile = smbFileList[smbFileList.length - 1];
|
|
|
|
|
// // String share = tempFile.getShare();
|
|
|
|
|
// // int index = tempFile.getCanonicalPath().indexOf(share);
|
|
|
|
|
// // return tempFile.getCanonicalPath().substring(index);
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// // } catch (SmbAuthException e) {
|
|
|
|
|
// try {
|
|
|
|
|
// String localpath = "//" + host + temp;
|
|
|
|
|
// File file = new File(localpath);
|
|
|
|
|
// File[] fileYearList = file.listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = yPattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (fileYearList != null && fileYearList.length > 0) {
|
|
|
|
|
// for (int i = fileYearList.length - 1; i >= 0; i--) {
|
|
|
|
|
// File[] fileYMList = fileYearList[i].listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = ymPattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (null != fileYMList && fileYMList.length > 0) {
|
|
|
|
|
// for (int j = fileYMList.length - 1; j >= 0; j--) {
|
|
|
|
|
// File[] fileYMDList = fileYMList[j].listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = ymdPattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (null != fileYMDList && fileYMDList.length > 0) {
|
|
|
|
|
// for (int k = fileYMDList.length - 1; k >= 0; k--) {
|
|
|
|
|
// File[] fileList = fileYMDList[k].listFiles(new FilenameFilter() {
|
|
|
|
|
//
|
|
|
|
|
// public boolean accept(File dir, String name) {
|
|
|
|
|
// Matcher m = fnamePattern.matcher(name);
|
|
|
|
|
// return m.matches();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (null != fileList && fileList.length > 0) {
|
|
|
|
|
// // return fileList[fileList.length - 1];
|
|
|
|
|
// File tempFile = fileList[fileList.length - 1];
|
|
|
|
|
// // TODO
|
|
|
|
|
// int index = tempFile.getAbsolutePath().indexOf(host);
|
|
|
|
|
// return tempFile.getAbsolutePath().substring(index + host.length());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e1) {
|
|
|
|
|
// e1.printStackTrace();
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
// // } catch (IOException e) {
|
|
|
|
|
// // e.printStackTrace();
|
|
|
|
|
// // return "";
|
|
|
|
|
// // }
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
|
|
// // System.err.println(FileUtil.sharedFileExists("10.124.41.200", "Administrator", "oracle", "jsproduct"));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static String ReadFile(String path) {
|
|
|
|
|
// String laststr = "";
|
|
|
|
|
// File file = new File(path);
|
|
|
|
|
// if (file.exists()) {
|
|
|
|
|
// BufferedReader reader = null;
|
|
|
|
|
// try {
|
|
|
|
|
// reader = new BufferedReader(new FileReader(file));
|
|
|
|
|
// String tempString = null;
|
|
|
|
|
// while ((tempString = reader.readLine()) != null) {
|
|
|
|
|
// laststr = laststr + tempString;
|
|
|
|
|
// }
|
|
|
|
|
// reader.close();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// WriteLog(e.toString());
|
|
|
|
|
// } finally {
|
|
|
|
|
// if (reader != null) {
|
|
|
|
|
// try {
|
|
|
|
|
// reader.close();
|
|
|
|
|
// } catch (IOException e1) {
|
|
|
|
|
// WriteLog(e1.toString());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// WriteLog("ReadFile " + path + " not exists ");
|
|
|
|
|
// }
|
|
|
|
|
// return laststr;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private static void WriteLog(String message) {
|
|
|
|
|
// // log.info(message);
|
|
|
|
|
// System.out.println(message);
|
|
|
|
|
// }
|
|
|
|
|
//}
|