-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilesUtil.java
More file actions
40 lines (35 loc) · 1.09 KB
/
Copy pathFilesUtil.java
File metadata and controls
40 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//I am a huge noob at creating and writing to files so this is probably really bad but it works for me so YOLO.
//In cause you are wondering, this class makes it super easy to create a file and append text to the file. :)
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class FilesUtil
{
//Change this variable in another class to change the text that gets appended to the file
public static String text = "";
public static void FileUtil() throws IOException
{
BufferedWriter bw = null;
try
{
//change "data.txt" to whatever you want to call your file
bw = new BufferedWriter(new FileWriter("data.txt", true));
bw.write(text);
bw.newLine();
bw.flush();
} catch (
IOException ioe)
{
ioe.printStackTrace();
} finally
{
if (bw != null) try
{
bw.close();
} catch (IOException ioe2)
{
ioe2.printStackTrace();
}
}
}
}