I'm working with a list and I am trying to print the contents to see if I am getting the result that I need. But when I println
it, the System.out.println
prints itself in it's own print (see below)
09-08 12:18:23.482 7718-7718/com.example I/System.out﹕ IMAGES are: [
09-08 12:18:23.482 7718-7718/com.example I/System.out﹕ [ 09-08 12:18:23.482 7718: 7718 I/System.out ]
__,__IwjV3bxFh7ADUCcZFCLsczmadO90TKeg.jpg
09-08 12:18:23.482 7718-7718/com.example I/System.out﹕ [ 09-08 12:18:23.482 7718: 7718 I/System.out ]
__,__CmonqJYgM8hiy4mHU9UmWDbNNbI4jjcb.jpg,
09-08 12:18:23.482 7718-7718/com.example I/System.out﹕ [ 09-08 12:18:23.482 7718: 7718 I/System.out ]
__,__AonUsfgTZpcdHUg4njUtExFC53E6IKRq.jpg, , , ]
Here is the code where I print the list:
final List<String> images = db.getAPIImages();
for (String e : images){
System.out.println("IMAGES are: " + e);
}
I'm not sure if this is just an issue with Android Studio, but when I look in my db, the System.out.println
isn't being stored so I believe it's just a print issue. I'd greatly appreciate some help.
USING Log.d
When using Log.d, I get the following output:
09-08 12:29:15.925 13757-13757/com.example D/IMAGES are:﹕ [
n8iQYdmU4HQkVJRTvgJfen7I8mUZ7oWW.jpg
poCcNRCTKeVtxbmyGiIaq5OfFg3b5Vce.jpg, , , , ]
From looking at that, I'm guessing a new line character is present between the two jpgs. How can I test for that and replace with a ","?
Including temp1.replace(System.getProperty("line.separator"),
has fixed my problem. Here is the full code:
for (String e : images){
String temp = e.replaceFirst(strSeparator, "");
String temp1 = temp.replace(strSeparator, ", ");
String temp2 = temp1.replace(System.getProperty("line.separator"), "");
System.out.println("IMAGES are: " + temp2);
}