There is such a class

public class UserData { public long UserTimestamp; public String UserName; public String UserURL; public int UserTimeOnPage; UserData(long UT, String UN, String UU, int UTOP){ UserTimestamp=UT; UserName=UN; UserURL=UU; UserTimeOnPage=UTOP; } } 

I get the objects from the input file, and add them to the list

 ArrayList<UserData> list=new ArrayList<UserData>(); try { br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) { // use comma as separator String[] country=line.split(cvsSplitBy); UserData current=new UserData(Long.parseLong(country[0]), country[1], country[2], Integer.parseInt(country[3])); list.add(current); } 

Input data is timestamp, user name, the amount of time he spent on the site. If the name of the user, the name of the site and the date when the user was on the site match, then you need to combine / merge two objects into one, calculate the average time on the site and throw the result on the console for example.

 пример входного файла: 1455812018,user2,wikipedia.org,100 1455812019,user10,hh.ru,30 1455812968,user3,google.com,60 1455812411,user10,hh.ru,90 1455812684,user3,vk.com,50 пример выходного файла: user2,wikipedia.org,100 user3,google.com,60 user3,vk.com,50 user10,hh.ru,60 

That is, two objects merged into one

It was

 1455812019 user10 http://hh.ru 30 1455812411 user10 http://hh.ru 90 

has become

 17-FEB-2016 user10,http://hh.ru,60 
  • 2
    you need to write the appropriate code to do this. no built-in mechanism. - Mikhail Vaysman
  • Make a function that will implement the actions described by you, which will return an object that is also described by you - bsuart
  • Objects can be for example 10 identical, or 7, the input data changes. - bulletproof

0