About 19,800,000 results
Open links in new tab
  1. How do I remove all Java class files from my entire project history …

    Aug 30, 2010 · If you want to permanently remove all class files from you entire history use hg convert and --filemap option to rewrite your repository and get rid of files from all revisions. However this solution alters revision ids.

  2. How to delete the contents of a file using the FileOutputStream class

    Apr 24, 2016 · Call File.delete() which deletes the file or directory denoted by this abstract pathname. File f = new File("foo.txt"); if (f.delete()) { System.out.println("file deleted"); }

  3. How to Clear a text file without deleting it? - Stack Overflow

    Jun 10, 2020 · If you want to clear the file without deleting may be you can workaround this public static void clearTheFile() { FileWriter fwOb = new FileWriter("FileName", false); PrintWriter pwOb = new PrintWriter(fwOb, false); pwOb.flush(); pwOb.close(); fwOb.close(); }

  4. Remove all .class files from folders in bash [duplicate]

    Mar 20, 2017 · I'm making a bash file to remove all .class files that java generates inside the src folder and it's subfolders. The structure is: project src /utils utils.class /game game.class gameManager.class

  5. Delete a File Using Java - GeeksforGeeks

    Jan 10, 2025 · There are two methods which could help us to remove the File using Java as mentioned below: 1. Using java.io.File.delete () Method. This method deletes the file or directory denoted by this abstract path name. Syntax: public boolean delete () Returns: It returns true, if and only if the file or the directory is successfully deleted. Example:

  6. Java File Class - GeeksforGeeks

    Jan 2, 2025 · Java File class contains several methods for working with the pathname, deleting and renaming files, creating new directories, listing the contents of a directory, and determining several common attributes of files and directories. It is an abstract representation of files and directory pathnames.

  7. can i remove .class files? : r/javahelp - Reddit

    Mar 29, 2021 · .class files are the compiled code. If you have the source code and can compile then yes you can remove them because you can easily recreate them by just compiling again. However, you will need the .class files to run your app.

  8. Java Delete Files - W3Schools

    To delete a file in Java, use the delete() method: import java.io.File; // Import the File class public class DeleteFile { public static void main(String[] args) { File myObj = new File("filename.txt"); if (myObj.delete()) { System.out.println("Deleted the file: " + myObj.getName()); } else { System.out.println("Failed to delete the file.");

  9. How to Clear the Content of a Text File in Java Without Deleting It?

    This guide explains how to clear the contents of a text file in Java while preserving the file itself. We will use the FileWriter class in overwrite mode to achieve this.

  10. How to delete a file or directory in Java using NIO API

    Tutorial shows how to delete a file or directory in Java using NIO API's java.nio.file.Files class's delete() and deleteIfExists() methods.