Reputation: 41
public static void load() {
try {
URL load = new URL("http://www.site.net/loader.php?username=" + "username" + "&password=" + "password");
BufferedReader in = new BufferedReader(
new InputStreamReader(load.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
if(inputLine.length() > 0){
put = inputLine;
put.split(":");
System.out.print(put);
}
}
} catch (IOException e){
e.printStackTrace();
}
}
As you see there, I'm trying to split the following data:
How do I remove the quotations and store it in an array, so I can load it up in an JList?
Put = String put;
Upvotes: 0
Views: 629
Reputation: 15180
The String split
method returns a String array. It does not change the original string, so this line does nothing:
put.split(":");
Instead, consider something like this. First split at the colon:
String[] parts = put.split(":");
Then for each part, remove the quotations:
for( int i = 0; i < parts.length; i++) {
parts[i] = parts[i].replaceAll("\"", "");
}
Then use the array of cleaned up strings to back a JList:
JList myList = new JList(parts);
Upvotes: 1