Hello,
I have got a problem with running the java program with batch file.
The program works well when I run with NetBeans or Eclipse.
When I want to add a property to List class with useDelimiter"\n" the batch file can't process it well and I got breaking line in the TXT file when I want to write it.
This is my method for addig car to the list:
private static void autokHozzaadasa() throws IOException, InterruptedException { sikeres = false; Scanner beMarkaMegnev = new Scanner(System.in).useDelimiter("\n"); Scanner be = new Scanner(System.in); String marka = null; String rendszam = null; String kobcenti = null; String evszam = null; String ertek = null; System.out.println("\nAutó hozzáadása!"); while (!sikeres) { System.out.print("Autó megnevezése: "); marka = beMarkaMegnev.next().toUpperCase(); System.out.print("Rendszám: "); rendszam = be.next().toUpperCase(); System.out.print("Köbcenti: "); kobcenti = be.next(); System.out.print("Évszám: "); evszam = be.next(); System.out.print("Ára: "); ertek = be.next(); if (vizsgal(kobcenti) && vizsgal(evszam) && vizsgal(ertek)) { sikeres = true; } else { sikeres = false; } for (Autok n : autok) { if (n.getRendszam().equals(rendszam)) { sikeres = false; } } if (!sikeres) { System.out.println("\nMár van ilyen rendszámmal rendelkező autó!\n"); } } if (sikeres) { autok.add(new Autok(marka, rendszam, Integer.parseInt(kobcenti), Integer.parseInt(evszam), Integer.parseInt(ertek))); System.out.println("\nSikeresen hozzáadtad ezt az autót:"); for (Autok n : autok) { if (n.getRendszam().equals(rendszam)) { System.out.println("\n\t" + n); } } autokKiir(); } System.out.println("\nVisszalépés a főmenübe: 4 másodperc múlva!\n"); Thread.sleep(4000); fomenu(); }
When the program is finishing with add to list and writing to the file I've got this txt datas:
CAR AND TYPE ABC-123;1842;2000;20000000
Then CAR AND TYPE must be seperator like this ";" without breaking lines.
Someone can solve my problem please?
Thanks