Bonjour,
j'ai un soucis avec mon code ci-dessous. Quand j'appelle findH depuis une autre classe, la fonction n'est pas appelée et rien ne se passe car même si le file retourné est null je suis censé avoir un msg mais non rien.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public static String findH(int type, String loc, int a, int r, boolean k, boolean f, double pric) throws IOException { int i = 0; String h, b, c, d, e, j; h = String.valueOf(type); b = String.valueOf(a); c = String.valueOf(r); d = String.valueOf(k); e = String.valueOf(f); j = String.valueOf(pric); String file2 = null; do { File file = new File("property" + i + ".txt"); if (file.exists()) { Scanner input = new Scanner(file); while (input.hasNextLine()) { if (h.equals(input.nextLine()) || loc.equals(input.nextLine()) || b.equals(input.nextLine()) || c.equals(input.nextLine()) || d.equals(input.nextLine()) || e.equals(input.nextLine()) || j.equals(input.nextLine())) { file2 = file.getName(); } } } i = i + 1; } while (i < 100000); return file2; }
Partager