fork download
  1. public class UserData {//implements Comparator<UserData>{
  2. private long UserTimestamp;
  3. public String UserName;
  4. public String UserURL;
  5. public int UserTimeOnPage;
  6. public int Day;
  7. public int Month;
  8.  
  9. public String toString(){
  10. return Day+Month+"\n "+UserTimestamp+" "+UserName+" "+UserURL+" "+UserTimeOnPage;
  11. }
  12. UserData(long UT, String UN, String UU, int UTOP){
  13.  
  14. UserTimestamp=UT;
  15. UserName=UN;
  16. UserURL=UU;
  17. UserTimeOnPage=UTOP;
  18. Date d=new Date(UserTimestamp);
  19. calendar.setTime(d);
  20. Day=calendar.get(Calendar.DATE);
  21. Month=calendar.get(Calendar.MONTH);
  22. //System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29. Comparator<UserData> comp = (UserData a, UserData b) -> {
  30. Integer first=a.Day;
  31. Integer second=b.Day;
  32. int k;
  33. k=first.compareTo(second);
  34. if(k==0){
  35. int f;
  36. String i=a.UserURL;
  37. String j=b.UserURL;
  38. f=i.compareTo(j);
  39. if(f==0){
  40. int g;
  41. g=a.UserName.compareTo(b.UserName);
  42. if(g==0){
  43. return g;
  44. }
  45. }
  46. return f;
  47. }
  48. return k;
  49. };
  50. TreeSet<UserData> list=new TreeSet<UserData>(comp);
  51. try {
  52.  
  53. br = new BufferedReader(new FileReader(csvFile));
  54.  
  55. while ((line = br.readLine()) != null) {
  56. // use comma as separator
  57. String[] country=line.split(cvsSplitBy);
  58. UserData current=new UserData(Long.parseLong(country[0]), country[1], country[2], Integer.parseInt(country[3]));
  59. list.add(current);
  60. }
  61.  
  62. for(UserData elem: list){
  63. System.out.println(elem+" ");
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:52: error: illegal start of type
		try {
		^
Main.java:52: error: ';' expected
		try {
		   ^
Main.java:54: error: <identifier> expected
			br = new BufferedReader(new FileReader(csvFile));
			  ^
Main.java:56: error: illegal start of type
			while ((line = br.readLine()) != null) {
			^
Main.java:56: error: illegal start of type
			while ((line = br.readLine()) != null) {
			       ^
Main.java:56: error: ')' expected
			while ((line = br.readLine()) != null) {
			        ^
Main.java:56: error: ';' expected
			while ((line = br.readLine()) != null) {
			            ^
Main.java:56: error: <identifier> expected
			while ((line = br.readLine()) != null) {
			                          ^
Main.java:56: error: ';' expected
			while ((line = br.readLine()) != null) {
			                            ^
Main.java:63: error: illegal start of type
			for(UserData elem: list){
			^
Main.java:63: error: ')' expected
			for(UserData elem: list){
			                 ^
Main.java:63: error: <identifier> expected
			for(UserData elem: list){
			                       ^
Main.java:65: error: reached end of file while parsing
			}
			 ^
13 errors
stdout
Standard output is empty