ADD NEW STRUCUTE

This commit is contained in:
2021-05-05 14:21:30 +02:00
parent fd96876544
commit e51ce37fe3
23 changed files with 354 additions and 106 deletions

View File

@@ -0,0 +1,38 @@
package Files;
import java.io.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
public class WriteFile {
BufferedWriter buffer = null;
public void WriteFile(String path, String input) throws Exception{
try {
File file = new File(path);
if (!file.exists()) {
file.createNewFile();
}
FileWriter fileWriter = new FileWriter(path);
buffer = new BufferedWriter(fileWriter);
buffer.write(input);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (buffer != null)
buffer.flush();
// buffer.close();
} catch (Exception ex) {
System.out.println("Error in closing the BufferedWriter" + ex);
}
}
}
}