日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java file ip_java常用工具类 IP、File文件工具类

發布時間:2023/12/15 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java file ip_java常用工具类 IP、File文件工具类 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文實例為大家分享了java常用工具類的具體實現代碼,供大家參考,具體內容如下

IP工具類

package com.jarvis.base.util;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.LineNumberReader;

/**

*

*

* @Title: IpMacUtil.java

* @Package com.jarvis.base.util

* @Description:Ip工具類。

* @version V1.0

*/

public class IpMacUtil {

/**

* 隱藏IP的最后一段

*

* @param ip

* 需要進行處理的IP

* @return 隱藏后的IP

*/

public static String hideIp(String ip) {

if (StringHelper.isEmpty(ip)) {

return "";

}

int pos = ip.lastIndexOf(".");

if (pos == -1) {

return ip;

}

ip = ip.substring(0, pos + 1);

ip = ip + "*";

return ip;

}

/**

* 獲取IP地址.

*

* @param request

* HTTP請求.

* @param response

* HTTP響應.

* @param url

* 需轉發到的URL.

*/

// public static String getIpAddr(HttpServletRequest request)

// {

// String ip = request.getHeader("x-forwarded-for");

// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))

// {

// ip = request.getHeader("Proxy-Client-IP");

// }

// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))

// {

// ip = request.getHeader("WL-Proxy-Client-IP");

// }

// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))

// {

// ip = request.getRemoteAddr();

// }

// return ip;

// }

/**

* 判斷該字串是否為IP

*

* @param ipStr

* IP字串

* @return

*/

public static boolean isIP(String ipStr) {

String ip = "(25[0-5]|2[0-4]\\d|1\\d\\d|\\d\\d|\\d)";

String ipDot = ip + "\\.";

return ipStr.matches(ipDot + ipDot + ipDot + ip);

}

/**

* 獲取客戶端Mac

*

* @param ip

* @return

*/

public static String getMACAddress(String ip) {

String str = "";

String macAddress = "";

try {

Process p = Runtime.getRuntime().exec("nbtstat -A " + ip);

InputStreamReader ir = new InputStreamReader(p.getInputStream());

LineNumberReader input = new LineNumberReader(ir);

for (int i = 1; i < 100; i++) {

str = input.readLine();

if (str != null) {

if (str.indexOf("MAC Address") > 1) {

macAddress = str.substring(str.indexOf("MAC Address") + 14, str.length());

break;

}

}

}

} catch (IOException e) {

return "";

}

return macAddress;

}

}

File文件工具類

package com.jarvis.base.util;

import java.io.ByteArrayInputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.List;

import java.util.StringTokenizer;

import java.util.zip.CRC32;

import java.util.zip.CheckedInputStream;

import org.apache.commons.io.FilenameUtils;

import org.dom4j.Document;

import org.dom4j.io.OutputFormat;

import org.dom4j.io.XMLWriter;

/**

*

*

* @Title: FileHelper.java

* @Package com.jarvis.base.util

* @Description:文件工具類

* @version V1.0

*/

public class FileHelper {

/**

* 1kb

*/

private final static int KB_1 = 1024;

/**

* 獲得文件的CRC32校驗和

*

* @param file

* 要進行校驗的文件

* @return

* @throws Exception

*/

public static String getFileCRCCode(File file) throws Exception {

FileInputStream is = new FileInputStream(file);

CRC32 crc32 = new CRC32();

CheckedInputStream cis = new CheckedInputStream(is, crc32);

byte[] buffer = null;

buffer = new byte[KB_1];

while (cis.read(buffer) != -1) {

}

is.close();

buffer = null;

return Long.toHexString(crc32.getValue());

}

/**

* 獲得字串的CRC32校驗和

*

* @param string

* 要進行校驗的字串

* @return

* @throws Exception

*/

public static String getStringCRCCode(String string) throws Exception {

ByteArrayInputStream inputStream = new ByteArrayInputStream(string.getBytes());

CRC32 crc32 = new CRC32();

CheckedInputStream checkedinputstream = new CheckedInputStream(inputStream, crc32);

byte[] buffer = null;

buffer = new byte[KB_1];

while (checkedinputstream.read(buffer) != -1) {

}

inputStream.close();

buffer = null;

return Long.toHexString(crc32.getValue());

}

/**

* 連接路徑和文件名稱,組成最后的包含路徑的文件名

*

* @param basePath

* 文件路徑

* @param fullFilenameToAdd

* 文件名稱

* @return

*/

public static String concat(String basePath, String fullFilenameToAdd) {

return FilenameUtils.concat(basePath, fullFilenameToAdd);

}

/**

* 獲得不帶文件擴展名的文件名稱

*

* @param filename

* 文件完整路徑

* @return 不帶擴展名的文件名稱

*/

public static String getBaseName(String filename) {

return FilenameUtils.getBaseName(filename);

}

/**

* 獲得帶擴展名的文件名稱

*

* @param filename

* 文件完整路徑

* @return 文件名稱

*/

public static String getFileName(String filename) {

return FilenameUtils.getName(filename);

}

/**

* 獲得文件的完整路徑,包含最后的路徑分隔條

*

* @param filename

* 文件完整路徑

* @return 目錄結構

*/

public static String getFullPath(String filename) {

return FilenameUtils.getFullPath(filename);

}

/**

* 獲得文件的完整路徑,不包含最后的路徑分隔條

*

* @param filename

* 文件完整路徑

* @return

*/

public static String getFullPathNoEndSeparator(String filename) {

return FilenameUtils.getFullPathNoEndSeparator(filename);

}

/**

* 判斷文件是否有某擴展名

*

* @param filename

* 文件完整路徑

* @param extension

* 擴展名名稱

* @return 若是,返回true,否則返回false

*/

public static boolean isExtension(String filename, String extension) {

return FilenameUtils.isExtension(filename, extension);

}

/**

* 判斷文件的擴展名是否是擴展名數組中的一個

*

* @param filename

* 文件完整路徑

* @param extensions

* 擴展名名稱

* @return 若是,返回true,否則返回false

*/

public static boolean isExtension(String filename, String[] extensions) {

return FilenameUtils.isExtension(filename, extensions);

}

/**

* 規范化路徑,合并其中的多個分隔符為一個,并轉化為本地系統路徑格式

*

* @param filename

* 文件完整路徑

* @return

*/

public static String normalize(String filename) {

return FilenameUtils.normalize(filename);

}

/**

* 規范化路徑,合并其中的多個分隔符為一個,并轉化為本地系統路徑格式,若是路徑,則不帶最后的路徑分隔符

*

* @param filename

* 文件完整路徑

* @return

*/

public static String normalizeNoEndSeparator(String filename) {

return FilenameUtils.normalizeNoEndSeparator(filename);

}

/**

* 把文件路徑中的分隔符轉換為unix的格式,也就是"/"

*

* @param path

* 文件完整路徑

* @return 轉換后的路徑

*/

public static String separatorsToUnix(String path) {

return FilenameUtils.separatorsToUnix(path);

}

/**

* 把文件路徑中的分隔符轉換為window的格式,也就是"\"

*

* @param path

* 文件完整路徑

* @return 轉換后的路徑

*/

public static String separatorsToWindows(String path) {

return FilenameUtils.separatorsToWindows(path);

}

/**

* 把文件路徑中的分隔符轉換當前系統的分隔符

*

* @param path

* 文件完整路徑

* @return 轉換后的路徑

*/

public static String separatorsToSystem(String path) {

return FilenameUtils.separatorsToSystem(path);

}

/**

* 提取文件的擴展名

*

* @param filename

* 文件名稱

* @return 文件擴展名,若沒有擴展名,則返回空字符串

*/

public static String getExtension(String filename) {

return FilenameUtils.getExtension(filename);

}

/**

* 移出文件的擴展名

*

* @param filename

* 文件名稱

* @return 若文件存在擴展名,則移出擴展名,然后返回移出后的值

*/

public static String removeExtension(String filename) {

return FilenameUtils.removeExtension(filename);

}

/**

* 清除一個目錄的內容,但不刪除此目錄

*

* @param directory

* 需要清除的目錄

* @return true:清除成功 false:清除失敗

*/

public static boolean cleanDirectory(File directory) {

try {

org.apache.commons.io.FileUtils.cleanDirectory(directory);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("清除目錄出錯");

}

return false;

}

/**

* 拷貝一個目錄的內容到另外一個目錄中

*

* @param srcDir

* 源目錄

* @param destDir

* 目的目錄

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyDirectory(File srcDir, File destDir) {

return copyDirectory(srcDir, destDir, true);

}

/**

* 拷貝一個目錄的內容到另外一個目錄中

*

* @param srcDir

* 源目錄

* @param destDir

* 目的目錄

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyDirectory(String srcDir, String destDir) {

return copyDirectory(new File(srcDir), new File(destDir));

}

/**

* 拷貝一個目錄的內容到另外一個目錄中

*

* @param srcDir

* 源目錄

* @param destDir

* 目的目錄

* @param preserveFileDate

* 是否保持文件日期

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyDirectory(File srcDir, File destDir, boolean preserveFileDate) {

try {

org.apache.commons.io.FileUtils.copyDirectory(srcDir, destDir, preserveFileDate);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("復制目錄出錯");

}

return false;

}

/**

* 拷貝源目錄的內容到目的目錄中(注:是拷貝到目的目錄的里面)

*

* @param srcDir

* 源目錄

* @param destDir

* 目的目錄

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyDirectoryToDirectory(File srcDir, File destDir) {

try {

org.apache.commons.io.FileUtils.copyDirectoryToDirectory(srcDir, destDir);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("復制目錄出錯");

}

return false;

}

/**

* 拷貝源目錄的內容到目的目錄中(注:是拷貝到目的目錄的里面)

*

* @param srcDir

* 源目錄

* @param destDir

* 目的目錄

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyDirectoryToDirectory(String srcDir, String destDir) {

return copyDirectoryToDirectory(new File(srcDir), new File(destDir));

}

/**

* 拷貝文件

*

* @param srcFile

* 源文件

* @param destFile

* 目的文件

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyFile(File srcFile, File destFile) {

return copyFile(srcFile, destFile, true);

}

/**

* 拷貝文件

*

* @param srcFile

* 源文件路徑

* @param destFile

* 目的文件路徑

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyFile(String srcFile, String destFile) {

return copyFile(new File(srcFile), new File(destFile));

}

/**

* 拷貝文件

*

* @param srcFile

* 源文件

* @param destFile

* 目的文件

* @param preserveFileDate

* 是否保留文件日期

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyFile(File srcFile, File destFile, boolean preserveFileDate) {

try {

org.apache.commons.io.FileUtils.copyFile(srcFile, destFile, preserveFileDate);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("復制文件出錯");

}

return false;

}

/**

* 拷貝文件到某目錄中

*

* @param srcFile

* 源文件

* @param destDir

* 目的目錄

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyFileToDirectory(File srcFile, File destDir) {

try {

org.apache.commons.io.FileUtils.copyFileToDirectory(srcFile, destDir);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("復制文件出錯");

}

return false;

}

/**

* 拷貝文件到某目錄中

*

* @param srcFile

* 源文件

* @param destDir

* 目的目錄

* @return true:拷貝成功 false:拷貝失敗

*/

public static boolean copyFileToDirectory(String srcFile, String destDir) {

return copyFileToDirectory(new File(srcFile), new File(destDir));

}

/**

* 刪除一個目錄和該目錄下的所有內容

*

* @param directory

* 需要刪除的目錄

* @return true:刪除成功 false:刪除失敗

*/

public static boolean deleteDirectory(String directory) {

try {

org.apache.commons.io.FileUtils.deleteDirectory(new File(directory));

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("刪除目錄出錯");

}

return false;

}

/**

* 刪除文件

*

* @param file

* 需要刪除的文件路徑

* @return true:刪除成功 false:刪除失敗

*/

public static boolean deleteFile(String file) {

try {

org.apache.commons.io.FileUtils.forceDelete(new File(file));

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("刪除文件出錯");

}

return false;

}

/**

* 遞歸創建目錄

*

* @param directory

* 目錄

* @return

*/

public static boolean createDirectory(String directory) {

try {

org.apache.commons.io.FileUtils.forceMkdir(new File(directory));

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("創建目錄出錯");

}

return false;

}

/**

* 讀入文件到字節數組中

*

* @param file

* 需要讀取的文件路徑

* @return 讀取的字節數組,若讀入失敗,則返回null

*/

public static byte[] readFileToByteArray(String file) {

try {

byte[] bytes = org.apache.commons.io.FileUtils.readFileToByteArray(new File(file));

return bytes;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("讀取文件出錯");

}

return null;

}

/**

* 讀入文件到字串中

*

* @param file

* 需要讀取的文件路徑

* @return 讀取的文件內容,若讀入失敗,則返回空字串

*/

public static String readFileToString(String file, String encoding) {

try {

if (StringHelper.isEmpty(encoding)) {

encoding = "GBK";

}

String content = org.apache.commons.io.FileUtils.readFileToString(new File(file), encoding);

return content;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("讀取文件出錯");

}

return "";

}

/**

* 讀入文件到字串中

*

* @param file

* 需要讀取的文件路徑

* @return 讀取的文件內容,若讀入失敗,則返回空字串

*/

public static String readFileToString(String file) {

return readFileToString(file, "GBK");

}

/**

* 讀入文本文件到一個按行分開的List中

*

* @param file

* 需要讀取的文件路徑

* @return 按行內容分開的List

*/

@SuppressWarnings("rawtypes")

public static List readLines(String file) {

return readLines(file, "GBK");

}

/**

* 讀入文本文件到一個按行分開的List中

*

* @param file

* 需要讀取的文件路徑

* @return 按行內容分開的List

*/

@SuppressWarnings("rawtypes")

public static List readLines(String file, String encoding) {

try {

if (StringHelper.isEmpty(encoding)) {

encoding = "GBK";

}

List lineList = org.apache.commons.io.FileUtils.readLines(new File(file), encoding);

return lineList;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("讀取文件出錯");

}

return null;

}

/**

* 遞歸求一個目錄的容量大小

*

* @param directory

* 需要計算容量的目錄路徑

* @return 容量的大小(字節數)

*/

public static long sizeOfDirectory(String directory) {

return org.apache.commons.io.FileUtils.sizeOfDirectory(new File(directory));

}

/**

* 寫字節數組到文件中,若文件不存在,則建立新文件

*

* @param file

* 需要寫的文件的路徑

* @param data

* 需要寫入的字節數據

* @return true:寫入成功 false:寫入失敗

*/

public static boolean writeToFile(String file, byte[] data) {

try {

org.apache.commons.io.FileUtils.writeByteArrayToFile(new File(file), data);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("寫文件出錯");

}

return false;

}

/**

* 寫字串到文件中,若文件不存在,則建立新文件

*

* @param file

* 需要寫的文件的路徑

* @param data

* 需要寫入的字串

* @return true:寫入成功 false:寫入失敗

*/

public static boolean writeToFile(String file, String data) {

return writeToFile(file, data, "GBK");

}

/**

* 寫字串到文件中,若文件不存在,則建立新文件

*

* @param file

* 需要寫的文件的路徑

* @param data

* 需要寫入的字串

* @param dncoding

* 文件編碼,默認為GBK

* @return true:寫入成功 false:寫入失敗

*/

public static boolean writeToFile(String file, String data, String encoding) {

try {

if (encoding == null || "".equals(encoding)) {

encoding = "GBK";

}

org.apache.commons.io.FileUtils.writeStringToFile(new File(file), data, encoding);

return true;

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("寫文件出錯");

}

return false;

}

/**

* 建立由filePathName指定的文件,若文件路徑中的目錄不存在,則先建立目錄

*

* @param filePathName

* 文件路徑全名

* @return

*/

public static boolean createNewFile(String filePathName) {

String filePath = FileHelper.getFullPath(filePathName);

// 若目錄不存在,則建立目錄

if (!FileHelper.exists(filePath)) {

if (!createDirectory(filePath)) {

return false;

}

}

try {

File file = new File(filePathName);

return file.createNewFile();

} catch (IOException ex) {

ex.printStackTrace();

System.err.println("創建文件出錯");

return false;

}

}

/**

* 判斷文件和目錄是否已存在

*

* @param filePath

* 文件和目錄完整路徑

* @return tru:存在 false:不存在

*/

public static boolean exists(String filePath) {

File file = new File(filePath);

return file.exists();

}

/**

* 判斷特定的路徑是否為文件

*

* @param filePath

* 文件完整的路徑

* @return 若是文件,則返回true,否則返回false

*/

public static boolean isFile(String filePath) {

File file = new File(filePath);

return file.isFile();

}

/**

* 判斷特定的路徑是否為目錄

*

* @param filePath

* 文件完整的路徑

* @return 若是目錄,則返回true,否則返回false

*/

public static boolean isDirectory(String filePath) {

File file = new File(filePath);

return file.isDirectory();

}

/**

* 更改文件的名稱,若不在同一個目錄下,則系統會移動文件

*

* @param srcFile

* 源文件路徑名稱

* @param destFile

* 目的文件路徑名稱

* @return

*/

public static boolean renameTo(String srcFile, String destFile) {

File file = new File(srcFile);

return file.renameTo(new File(destFile));

}

/**

*

* 描述:根據document生成Xml文件 作者:劉寶 時間:Jun 9, 2010 3:16:11 PM

*

* @param fileName

* 生成文件的路徑

* @param document

* @param encoding

* 編碼格式

* @return

*/

public static boolean WriteToXMLFile(String fileName, Document document, String encoding) {

createNewFile(fileName);

boolean success = false;

/** 格式化輸出,類型IE瀏覽一樣 */

OutputFormat format = OutputFormat.createPrettyPrint();

/** 指定XML編碼 */

format.setEncoding(encoding);

XMLWriter writer = null;

try {

/** 將document中的內容寫入文件中 */

writer = new XMLWriter(new FileOutputStream(new File(fileName)), format);

writer.write(document);

writer.flush();

success = true;

/** 執行成功,需返回true */

} catch (Exception ex) {

ex.printStackTrace();

System.err.println("寫文件出錯");

} finally {

if (writer != null) {

try {

writer.close();

writer = null;

} catch (IOException e) {

e.printStackTrace();

System.err.println("Convert code Error");

}

}

}

return success;

}

/**

* 獲取文件的后綴名并轉化成大寫

*

* @param fileName

* 文件名

* @return

*/

public String getFileSuffix(String fileName) throws Exception {

return fileName.substring(fileName.lastIndexOf(".") + 1,

fileName.length()).toUpperCase();

}

/**

* 創建多級目錄

*

* @param path

* 目錄的絕對路徑

*/

public void createMultilevelDir(String path) {

try {

StringTokenizer st = new StringTokenizer(path, "/");

String path1 = st.nextToken() + "/";

String path2 = path1;

while (st.hasMoreTokens()) {

path1 = st.nextToken() + "/";

path2 += path1;

File inbox = new File(path2);

if (!inbox.exists())

inbox.mkdir();

}

} catch (Exception e) {

System.out.println("目錄創建失敗" + e);

e.printStackTrace();

}

}

/**

* 刪除文件/目錄(遞歸刪除文件/目錄)

*

* @param path

* 文件或文件夾的絕對路徑

*/

public void deleteAll(String dirpath) {

if (dirpath == null) {

System.out.println("目錄為空");

} else {

File path = new File(dirpath);

try {

if (!path.exists())

return;// 目錄不存在退出

if (path.isFile()) // 如果是文件刪除

{

path.delete();

return;

}

File[] files = path.listFiles();// 如果目錄中有文件遞歸刪除文件

for (int i = 0; i < files.length; i++) {

deleteAll(files[i].getAbsolutePath());

}

path.delete();

} catch (Exception e) {

System.out.println("文件/目錄 刪除失敗" + e);

e.printStackTrace();

}

}

}

/**

* 文件/目錄 重命名

*

* @param oldPath

* 原有路徑(絕對路徑)

* @param newPath

* 更新路徑

* @author lyf 注:不能修改上層次的目錄

*/

public void renameDir(String oldPath, String newPath) {

File oldFile = new File(oldPath);// 文件或目錄

File newFile = new File(newPath);// 文件或目錄

try {

boolean success = oldFile.renameTo(newFile);// 重命名

if (!success) {

System.out.println("重命名失敗");

} else {

System.out.println("重命名成功");

}

} catch (RuntimeException e) {

e.printStackTrace();

}

}

/**

* 新建目錄

*/

public static boolean newDir(String path) throws Exception {

File file = new File(path);

return file.mkdirs();//創建目錄

}

/**

* 刪除目錄

*/

public static boolean deleteDir(String path) throws Exception {

File file = new File(path);

if (!file.exists())

return false;// 目錄不存在退出

if (file.isFile()) // 如果是文件刪除

{

file.delete();

return false;

}

File[] files = file.listFiles();// 如果目錄中有文件遞歸刪除文件

for (int i = 0; i < files.length; i++) {

deleteDir(files[i].getAbsolutePath());

}

file.delete();

return file.delete();//刪除目錄

}

/**

* 更新目錄

*/

public static boolean updateDir(String path, String newPath) throws Exception {

File file = new File(path);

File newFile = new File(newPath);

return file.renameTo(newFile);

}

// 刪除文件夾

// param folderPath 文件夾完整絕對路徑

public static void delFolder(String folderPath) {

try {

delAllFile(folderPath); // 刪除完里面所有內容

String filePath = folderPath;

filePath = filePath.toString();

java.io.File myFilePath = new java.io.File(filePath);

myFilePath.delete(); // 刪除空文件夾

} catch (Exception e) {

e.printStackTrace();

}

}

// 刪除指定文件夾下所有文件

// param path 文件夾完整絕對路徑

public static boolean delAllFile(String path) {

boolean flag = false;

File file = new File(path);

if (!file.exists()) {

return flag;

}

if (!file.isDirectory()) {

return flag;

}

String[] tempList = file.list();

File temp = null;

for (int i = 0; i < tempList.length; i++) {

if (path.endsWith(File.separator)) {

temp = new File(path + tempList[i]);

} else {

temp = new File(path + File.separator + tempList[i]);

}

if (temp.isFile()) {

temp.delete();

}

if (temp.isDirectory()) {

delAllFile(path + "/" + tempList[i]);// 先刪除文件夾里面的文件

delFolder(path + "/" + tempList[i]);// 再刪除空文件夾

flag = true;

}

}

return flag;

}

public static void main(String d[]) throws Exception{

//deleteDir("d:/ff/dddf");

updateDir("D:\\TOOLS\\Tomcat 6.0\\webapps\\BCCCSM\\nationalExperiment/22222", "D:\\TOOLS\\Tomcat 6.0\\webapps\\BCCCSM\\nationalExperiment/224222");

}

}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的java file ip_java常用工具类 IP、File文件工具类的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。