forked from Hevanly-Fire/Java-Encode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewEntry.java
More file actions
55 lines (53 loc) · 1.24 KB
/
newEntry.java
File metadata and controls
55 lines (53 loc) · 1.24 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// To enter new expenses INPUT-> 2,850
/*
HERE YOU CAN ENTER YOUR expenses
CATEGORIES-
1
2
..
n
INPUT-> 2 850
*/
import java.io.*;
import java.time.format.DateTimeFormatter;
import java.time.*;
public class newEntry
{
public String exp[];
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy");
LocalDateTime now = LocalDateTime.now();
public newEntry(String username, int cat, int exp) throws Exception
{
try
{
String fileName = "data/" + username+ ".txt";
File userFile = new File(fileName);
if(userFile.exists())
{
FileWriter fw = new FileWriter(fileName, true);
String stamp = "" + cat + "/" + exp + "/" + dtf.format(now)+"\n";
//System.out.println(stamp);
fw.append(stamp);
fw.close();
System.out.println("Entry done!");
}
else
{
userFile.createNewFile();
FileWriter fw = new FileWriter(fileName, true);
String stamp = "" + cat + "/" + exp + "/" + dtf.format(now) + "\n";
//System.out.println(stamp);
fw.write(stamp);
fw.close();
System.out.println("Entry done!");
}
}
catch(Exception E)
{
System.out.println(E);
}
}
public void main()
{
}
}