本地檔案操作類

2021-08-20 18:44:46 字數 2097 閱讀 6180

public class locahostutils 

file file2 = new file(file1, bundname + filenamee);

if (!file2.exists()) catch (ioexception e)

}//一行一行的讀

filewriter fw = null;

bufferedwriter bw = null;

//string datetime = ""

;try catch (ioexception e)

filename

= file2;

} //建立資料夾

public static boolean creatfolder(string foldername)

return f;

} //通過路徑找到這個檔案的名字

public static string getfilename(string pathandname) else

}//這個是將資料庫裡面的路徑尋找到

public static void

getjson(listpath)

for (int i = 0

; i < path.size(); i++)

}/**

* 複製單個檔案

*@param

oldpath

string 原檔案路徑 如:c:/fqf.txt

*@param

newpath

string 複製後路徑 如:f:/fqf.txt

*/public static void

copyfile(string oldpath, string newpath)

fs.flush();

//重新整理流

fs.close();

//關閉

instream.close();

//關閉輸入流

} } catch (exception e)

}//將bitmap 型別的儲存到本地

public static string sacebitmap(bitmap bitmap, string name, string projectname, string mfloorname)

file file1 = new file(file + file.separator

, timestamp

+ "_" + name + ".jpeg");

try catch (ioexception e)

return file1.getabsolutepath();

} //將bitmap 型別的儲存到本地

public static string sacedtbitmap(bitmap bitmap, string name)

file file1 = new file(file + file.separator

, timestamp

+ "_" + name + ".jpeg");

try catch (ioexception e)

return file1.getabsolutepath();

} //刪除本地檔案

public static boolean

deletefile(string filepath)

if (!file.isfile())

return file.delete();

} //判斷資料夾是不是空的

public static boolean

folderisblank(string foldername) else

}return false;

}

//建立方法,刪除資料夾中的所有檔案包括資料夾本身

public void

deletefile(string file)

else

}//刪除空資料夾

directory.delete(file);

}}

本地檔案簡單操作

首先大致說說c 檔案本地檔案操作 在說之前我們知道乙個檔案.txt,excel,dll等都是儲存在硬碟或叫磁碟上面,然後知道了c 是通過操作流來讀取和寫入這些檔案 那麼用這裡就用到了兩個重要的操縱。filestream和streamwrite,streamreader,memorystream等,它...

docker操作本地檔案

docker使用過程中,如果要操作本地檔案,就需要在操作的目錄中建立乙個docker compose.yml檔案。docker compose.yml version 3 services web image tesseractshadow tesseract4re build container ...

cordova操作Android本地檔案系統

cordova提供了file外掛程式,這個外掛程式可以訪問手機上大部分檔案和資料夾,當然,首先肯定是需要安裝cordova以及安裝它的外掛程式 cordova plugin file 了,具體如何安裝請讀者自行檢視官網,筆者就不再贅述 1.cordova 建立本地檔案 在訪問android本地系統檔...