-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClsse2.java
78 lines (68 loc) · 2.03 KB
/
Clsse2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Clsse2 {
public boolean controllofile() throws IOException {
try {
FileReader InputFile = new FileReader("FileInventario.txt");
BufferedReader righe = new BufferedReader(InputFile);
righe.close();
return false;
} catch (FileNotFoundException E) {
System.out.println("Errore 404: File non trovato");
return true;
}
}
public String[] leggifile() throws IOException {
FileReader InputFile = new FileReader("FileInventario.txt");
BufferedReader righe = new BufferedReader(InputFile);
ArrayList<String> lista = new ArrayList<String>();
String riga = null;
do {
riga = righe.readLine();
if (riga == null)
break;
lista.add(riga);
} while (true);
righe.close();
return lista.toArray(new String[lista.size()]);
}
public boolean scrivifile (char cat,char unit,int quant,double pre, String codUn, String nom, String caratt) throws IOException{
try {
FileWriter OutputFile = new FileWriter("FileInventario.txt",true);
BufferedWriter A = new BufferedWriter(OutputFile);
A.write("\r"+cat+";"+unit+";"+quant+";"+pre+";"+codUn+";"+nom+";"+caratt);
A.flush();
A.close();
return false;
} catch (FileNotFoundException E) {
System.out.println("Errore 404: File non trovato");
return true;
}
}
public void Ricercatramite (String cosa, String scan) {
switch (cosa)
{
// case nome:for (int x=0;x<ProgettoMain.Raccoglitore.size();)
// {
// String NomeEsistente =ProgettoMain.Nomi.get(x);
// String Nomericerca =scan;
// if
//
// }
// case codice_univoco:; break;
// case caratteristiche:; break;
//
//
}
}
public void Vendeta (String CodiceDaCercare) throws IOException
{
BufferedReader in = new BufferedReader(new FileReader("FileInventario.txt"));
String RIcerca = in.readLine();
if (RIcerca==CodiceDaCercare)
{
System.out.print(RIcerca);
}
}
}