-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroupDetails.java
68 lines (57 loc) · 1.65 KB
/
GroupDetails.java
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
56
57
58
59
60
61
62
63
64
65
66
67
68
//import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;
import java.util.regex.Pattern;
public class GroupDetails{
private String currentUserText;
public void createGroup(String groupName, CreateNewGroupPage createNewGroupPage){
//getting current user name
try{
File file = new File("currentUser.txt");
Scanner sc= new Scanner(file);
if(sc.hasNextLine()){
currentUserText= sc.nextLine();
currentUserText=currentUserText.substring(0,currentUserText.indexOf("@"));
}
}
catch(Exception io){
io.printStackTrace();
}
finally{
//adding grouplink
try{
String user=currentUserText+"-groupList.txt";
File currentUserGroupList= new File(user);
Scanner sc = new Scanner(currentUserGroupList);
boolean linkExists=false;
String link=currentUserText+"-"+groupName;
while (sc.hasNextLine()){
if(sc.nextLine().equals(link)){
CreateNewGroupPage.LabelError1.setBounds(2000,2000,400,18);
CreateNewGroupPage.LabelError2.setBounds(430,320,400,18);
linkExists=true;
//CreateNewGroupPage createNewGroupPage= new CreateNewGroupPage();
//createNewGroupPage.setVisible(true);
break;
}
}
if(!linkExists)
{
FileWriter writer = new FileWriter(currentUserGroupList, true);
writer.write(currentUserText+"-"+groupName+"\n");
writer.flush();
writer.close();
GroupsPage groupsPage = new GroupsPage();
createNewGroupPage.setVisible(false);
groupsPage.setVisible(true);
}
}
catch(Exception io){
io.printStackTrace();
}
}
}
}