Advertisement
Guest User

ss

a guest
Nov 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3. import java.io.*;
  4. import main.Grindjuoste;
  5.  
  6.  
  7. public class Main {
  8.  
  9.  
  10. public static void main(String[] args) throws FileNotFoundException {
  11. ArrayList<Grindjuoste> Grind = new ArrayList();
  12. Scanner sc = null;
  13. try {
  14. sc = new Scanner(new File("data.txt"));
  15. String code = null;
  16. String xa = null;
  17. while (sc.hasNextLine()) {
  18. String line = sc.next();
  19.  
  20. if (line.trim().endsWith(":")) {
  21. code = line;
  22. // System.out.println(code);
  23. }
  24. String pav = sc.next();
  25. String toliau = sc.next();
  26. double skaicius = 0;
  27. while (true){
  28. try {
  29. skaicius = Double.parseDouble(toliau);
  30. toliau = sc.next();
  31.  
  32. break;
  33. }
  34. catch(Exception r){
  35. pav=pav+" "+toliau;
  36. toliau=sc.next();
  37. }
  38. }
  39.  
  40. // System.out.println(pav);
  41. double ilg = skaicius;
  42. toliau=sc.next();
  43. double plot = Double.parseDouble(toliau);
  44. toliau=sc.next();
  45. toliau=sc.next();
  46. double aukst = Double.parseDouble(toliau);
  47. toliau=sc.next();
  48. double kaina = Double.parseDouble(toliau);
  49. System.out.println(code+" "+pav+" "+ilg+" "+plot+" "+aukst+" "+kaina);
  50. //System.out.println(code);
  51. // Grind.add(code, pav, ilg, plot, aukst, kaina);
  52. }
  53. } catch(
  54. Exception e)
  55.  
  56. {
  57. e.printStackTrace();
  58. } finally
  59.  
  60. {
  61. if (sc != null) {
  62. sc.close();
  63. }
  64. }
  65.  
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement