Artikel ini menjelaskan implementasi Java dari file pencocokan fuzzy di bawah fungsi folder dan penghapusan. Bagikan untuk referensi Anda, sebagai berikut:
Paket com.wyebd.gis; import java.io.file;/** * @title: delfiles.java * @package com.wyebd.gis * @description: * @Author lisr * @Date 7 Maret 2012 5:36:03 pm * @version v1.0 */Public classion delels 2012 5:36:03 pm * @version v1.0 */Public Counciles Delfs 211 args * @return void * @author lisr * @Date 7 Mar 2012 5:36:04 PM * @throws * // Gunakan untuk menghapus file dengan st dengan header public static boolean delfilesbypath (string path, string str) {// deskripsi parameter ------- Path: Path to the Folder of the Folder of the Folder of the Folder dari The Folder dari The Folder dari The Folder dari The Folder dari The The Folder dari The Folder dari The Folder dari The Folder To The Folder dari The Folder dari The Folder dari The Flik Dihapus ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- System.out.println ("Nama file yang akan dihapus:"+tempfile [i] .getName ()); boolean del = deleteFile (path+tempfile [i] .getName ()); if (del) {System.out.println ("File"+tempfile [i] .getName ()+"hapus berhasil"); b = true; } else {System.out.println ("File"+Tempfile [i] .getName ()+"Hapus gagal"); }}} return b; } private static boolean deleteFile (string path) {System.out.println (path); boolean del = false; File file = file baru (path); if (file.isfile ()) {file.delete (); del = true; } return del; } public static void main (string [] args) {// TODO Metode yang dihasilkan otomatis Path string string = "d:/temp/"; String str = "44_"; if (delfilesbypath (path, str)) {system.out.println (path+"semuanya telah dihapus dengan sukses!"); } else {System.out.println (file yang berisi "+str+" di path+"telah gagal dihapus atau file tersebut tidak ada di folder ini!"); }}} Paket com.wyebd.gis; import java.io.file;/** * @title: delfiles.java * @package com.wyebd.gis * @description: * @Author lisr * @Date 7 Maret 2012 5:36:03 pm * @version v1.0 */Public classion delels 2012 5:36:03 pm * @version v1.0 */Public Counciles Delfs 211 args * @return void * @author lisr * @Date 7 Mar 2012 5:36:04 PM * @throws * // Gunakan untuk menghapus file dengan st dengan header public static boolean delfilesbypath (string path, string str) {// deskripsi parameter ------- Path: Path to the Folder of the Folder of the Folder of the Folder dari The Folder dari The Folder dari The Folder dari The Folder dari The The Folder dari The Folder dari The Folder dari The Folder To The Folder dari The Folder dari The Folder dari The Flik Dihapus ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- tempfile [i] .delete (); b = true; }} return b; } public static void main (string [] args) {string path = "d:/temp/"; String str = "44_"; if (delfilesbypath (path, str)) {system.out.println (path+"berisi"+str+"dan telah dihapus dengan sukses!"); } else {System.out.println (path+"berisi"+str+"dan telah gagal untuk menghapus atau file tersebut tidak ada di folder ini!"); }}} Secara pribadi, saya pikir: jika Anda ingin mencapai pencocokan fuzzy yang lebih canggih, Anda hanya perlu menggunakan metode indexOf() String, dan semua file yang berisi string ini akan dihapus bersama!
Untuk informasi lebih lanjut tentang algoritma Java, pembaca yang tertarik dengan situs ini dapat melihat topik: "Ringkasan File Java dan Keterampilan Operasi Direktori", "Tutorial tentang Struktur Data Java dan Algoritma", "Ringkasan Keterampilan Operasi Java Dom" dan "Ringkasan Keterampilan Operasi Java Cache"
Saya harap artikel ini akan membantu pemrograman Java semua orang.