Removed unwanted chars from return String of ArrayList

get_destinations_methods
Selim Eser 2024-06-09 15:58:25 +02:00
parent 9db8247e14
commit 671553bd19
1 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package de.hs_mannheim.domain; package de.hs_mannheim.domain;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URI; import java.net.URI;
@ -54,16 +55,19 @@ public class System {
TreeSet<String> zip_set = new TreeSet<>(); TreeSet<String> zip_set = new TreeSet<>();
try (InputStream inputStream = Main.class.getResourceAsStream("/zip.csv"); InputStream inputStream = Main.class.getResourceAsStream("/zip.csv");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
if(line.contains("hometown_or_zip")&&zip_set.size()<200) if(line.contains(hometown_or_zip)&&zip_set.size()<200){
line = line.replace("\"", "");
zip_set.add(line); zip_set.add(line);
}
} }
} catch (IOException e) {
} catch (Exception e) {} e.printStackTrace();
}
return new ArrayList<>(zip_set); return new ArrayList<>(zip_set);
} }