daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Mar 20th, 2019 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.util.ArrayList;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.     File kilden = new File("valutakurser.csv");
  8.  
  9.     ArrayList<Valuta> valutaerFraFiler = lesFraCSVFil(kilden);
  10.  
  11.     System.out.println(valutaerFraFiler);
  12. }
  13.  
  14. private static ArrayList<Valuta> lesFraCSVFil(File filSomLesesFra) {
  15.     ArrayList<Valuta> valutaerFraFil = new ArrayList<>();
  16.     try (BufferedReader bufretLeser = new BufferedReader(new FileReader(filSomLesesFra))) {
  17.         String linje;
  18.         while( (linje = bufretLeser.readLine()) != null ){
  19.             String[] deler = linje.split(";");
  20.  
  21.             Valuta enValuta = new Valuta(deler[0], deler[1], deler[2], deler[3]);
  22.  
  23.             valutaerFraFil.add(enValuta);
  24.         }
  25.  
  26.  
  27.     } catch (IOException e) {
  28.         System.out.println(e);
  29.     }
  30.  
  31.     return valutaerFraFil;
  32. }
  33. }
  34.      
  35. public Valuta(String land, String landskode, String valutakodenavn, int
  36. valutakurs) {
  37.     this.land = land;
  38.     this.landskode = landskode;
  39.     this.valutakodenavn = valutakodenavn;
  40.     this.valutakurs = valutakurs;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top