fork download
  1. /* package whatever; // don't place package name! */
  2. import java.io.BufferedReader;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.*;
  7.  
  8.  
  9. public class UserData {
  10. private String UserTimestamp;
  11. private String UserName;
  12. private String UserURL;
  13. private String UserTimeOnPage;
  14.  
  15. public void show (){
  16. System.out.println(UserTimestamp+" "+UserName+" "+UserURL+" "+UserTimeOnPage);
  17. }
  18. public boolean compare(UserData dd){
  19.  
  20. return true;
  21. }
  22. UserData(String UT, String UN, String UU, String UTOP){
  23.  
  24. UserTimestamp=UT;
  25. UserName=UN;
  26. UserURL=UU;
  27. UserTimeOnPage=UTOP;
  28. }
  29. }
  30.  
  31. public class User {
  32.  
  33. public static void main(String[] args) {
  34.  
  35. User obj = new User();
  36. obj.getData();
  37.  
  38. }
  39.  
  40. public void getData() {
  41.  
  42. String csvFile = "D:\\JAVA\\Сорц Джвава\\Input\\file1.csv";
  43. BufferedReader br = null;
  44. String line ="";
  45. String cvsSplitBy = ",";
  46. //Map staff=new HashMap<String, UserData>();
  47. ArrayList<UserData> list = new ArrayList<UserData>();
  48. int i=0;
  49. try {
  50.  
  51. br = new BufferedReader(new FileReader(csvFile));
  52. while ((line = br.readLine()) != null) {
  53.  
  54. // use comma as separator
  55. String[] country=line.split(cvsSplitBy);
  56. UserData ff=new UserData(country[0], country[1], country[2], country[3]);
  57. list.add(i,ff);
  58. i++;
  59.  
  60. }
  61. for(int j=0; j<5; j++){
  62. list.get(j);
  63. }
  64. UserData dd=list.get(0);
  65. dd.show();
  66.  
  67. } catch (FileNotFoundException e) {
  68. e.printStackTrace();
  69. } catch (IOException e) {
  70. e.printStackTrace();
  71. } finally {
  72. if (br != null) {
  73. try {
  74. br.close();
  75. } catch (IOException e) {
  76. e.printStackTrace();
  77. }
  78. }
  79. }
  80.  
  81. System.out.println("Done");
  82. }
  83.  
  84. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: class UserData is public, should be declared in a file named UserData.java
public class UserData {
       ^
Main.java:31: error: class User is public, should be declared in a file named User.java
public class User {
       ^
2 errors
stdout
Standard output is empty