ADD : NEW Format for all the code with prettier
This commit is contained in:
@@ -1,38 +1,34 @@
|
||||
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();
|
||||
}
|
||||
BufferedWriter buffer = null;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user