Guest User

Untitled

a guest
Jun 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. I Did It Your Way, 11.95
  2. The History of Scotland, 14.50
  3. Learn Calculus in One Day, 29.95
  4. Feel the Stress, 18.50
  5. Great Poems, 12.95
  6. Europe on a Shoestring, 10.95
  7. The Life of Mozart, 14.50
  8.  
  9. BufferedReader r = new BufferedReader(new FileReader("file.txt"));
  10. List<String> titles = new ArrayList<String>();
  11. List<Double> prices = new ArrayList<Double>();
  12.  
  13. while ((String line = r.readLine()) != null) {
  14. String[] tokens = line.split(",");
  15. titles.add(tokens[0].trim());
  16. prices.add(Double.parseDouble(tokens[1].trim()));
  17. }
  18.  
  19. r.close();
  20.  
  21. CSVReader reader = new CSVReader(new FileReader("test.txt"));
  22. List myEntries = reader.readAll();
  23.  
  24. int noOfEntries=myEntries.size();
  25.  
  26. String[] titles=new String[noOfEntries];
  27. String[] price=new String[noOfEntries];
  28.  
  29. String[] entry=null;
  30. int i=0;
  31. for(Object entryObject:myEntries){
  32. entry=(String[]) entryObject;
  33. titles[i]=entry[0];
  34. price[i]=entry[1];
  35. i++;
  36. }
Add Comment
Please, Sign In to add comment