Lettura numeriContiCorrenti + modifica log
This commit is contained in:
@@ -22,8 +22,6 @@ public class ContoCorrente {
|
||||
|
||||
private static ArrayList<Integer> numeriContiCorrenti = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldo,
|
||||
int numeroContoCorrente) {
|
||||
this.nome = nome;
|
||||
@@ -40,6 +38,10 @@ public class ContoCorrente {
|
||||
return numeriContiCorrenti;
|
||||
}
|
||||
|
||||
public static void setNumeriContiCorrenti(List<Integer> numeriContiCorrenti) {
|
||||
ContoCorrente.numeriContiCorrenti = (ArrayList<Integer>)numeriContiCorrenti;
|
||||
}
|
||||
|
||||
public int getNumeroContoCorrente() {
|
||||
return numeroContoCorrente;
|
||||
}
|
||||
|
||||
@@ -87,12 +87,12 @@ public class MyBank {
|
||||
pausa();
|
||||
break;
|
||||
default:
|
||||
System.out.println("Opzione non valida.");
|
||||
System.out.println(ERRORE_GENERICO);
|
||||
pausa();
|
||||
break;
|
||||
}
|
||||
} catch (InputMismatchException _) {
|
||||
System.out.println("Errore: scelta non valida.");
|
||||
System.out.println(ERRORE_GENERICO);
|
||||
pausa();
|
||||
}
|
||||
} while (scelta != 0);
|
||||
@@ -110,13 +110,15 @@ public class MyBank {
|
||||
|
||||
if (percorsoConti.exists() && percorsoConti.listFiles().length != 0) {
|
||||
for (File conto : percorsoConti.listFiles()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (conto.getName().substring(conto.getName().lastIndexOf(".")).equals("json")) {
|
||||
try (BufferedReader bf = new BufferedReader(new FileReader(conto))) {
|
||||
for (String rigaJSON : bf.readAllLines()) {
|
||||
sb.append(rigaJSON);
|
||||
}
|
||||
conti.add(mapper.readValue(sb.toString(), ContoCorrente.class));
|
||||
|
||||
conti.add(mapper.readValue(bf.readAllAsString(), ContoCorrente.class));
|
||||
|
||||
ArrayList<Integer> numeriContiCorrenti = (ArrayList<Integer>) ContoCorrente.getNumeriContiCorrenti();
|
||||
numeriContiCorrenti.add(conti.getLast().getNumeroContoCorrente());
|
||||
ContoCorrente.setNumeriContiCorrenti(numeriContiCorrenti);
|
||||
|
||||
} catch (Exception _) {
|
||||
System.out.println("Errore nella lettura del file di conto corrente.");
|
||||
}
|
||||
@@ -297,7 +299,7 @@ public class MyBank {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.sss dd/MM/yyyy");
|
||||
try (BufferedWriter bw = new BufferedWriter(
|
||||
new FileWriter(PATH_CONTI + "movimenti_" + numeroContoCorrente + ".txt"))) {
|
||||
new FileWriter(PATH_CONTI + "movimenti_" + numeroContoCorrente + ".txt", true))) {
|
||||
sb.append("[");
|
||||
sb.append(sdf.format(new Date()));
|
||||
sb.append("] ");
|
||||
|
||||
Reference in New Issue
Block a user