henou23
Messages postés10Date d'inscriptionmercredi 30 septembre 2009StatutMembreDernière intervention 6 octobre 2009
-
5 oct. 2009 à 20:47
henou23
Messages postés10Date d'inscriptionmercredi 30 septembre 2009StatutMembreDernière intervention 6 octobre 2009
-
6 oct. 2009 à 00:56
Bonjour
j'ai un programme ci dessous java qui marche trés bien et il fait supprimer des ligne dans mon fichier texte mais moi je veux bien supprimer des lignes dans un fichier.java et non pas .txt merci de m'aidez
public class FileUtil {
public void removeLineFromFile(String file, String lineToRemove) {
try {
File inFile = new File(file);
if (!inFile.isFile()) {
System.out.println("Parameter is not an existing file");
return;
}
//Construct the new file that will later be renamed to the original filename.
File tempFile = new File(inFile.getAbsolutePath() + ".tmp");
BufferedReader br = new BufferedReader(new FileReader(file));
PrintWriter pw = new PrintWriter(new FileWriter(tempFile));
String line = null;
//Read from the original file and write to the new
//unless content matches data to be removed.
while ((line = br.readLine()) != null) {