Untitled
unknown
plain_text
2 years ago
1.2 kB
9
Indexable
import java.io.*;
public class ChangeFileEncoding {
public static void main(String[] args) {
// Spécifiez le chemin du fichier source et la destination
String sourceFilePath = "chemin/vers/votre/fichier/source.txt";
String destinationFilePath = "chemin/vers/votre/fichier/destination.txt";
try {
// Créez un flux d'entrée avec l'encodage d'origine
FileInputStream fis = new FileInputStream(sourceFilePath);
InputStreamReader isr = new InputStreamReader(fis, "ENCODAGE_ORIGINE");
// Créez un flux de sortie avec l'encodage UTF-8
FileOutputStream fos = new FileOutputStream(destinationFilePath);
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
int c;
while ((c = isr.read()) != -1) {
osw.write(c);
}
// Fermez les flux
isr.close();
osw.close();
System.out.println("L'encodage du fichier a été changé en UTF-8 avec succès.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Editor is loading...