• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need to Prevent Quotes When String is Empty

 
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use the following code to generate a CSV file used to print a label. When one of the noteArray elements is empty it prints double quotes for that line on the label. I need it to leave the line blank.

Here is the compiledLabelBodyString output: (In this case noteArray.get(2).get(0) is empty)
compliedLabelBodyString: "861615-001.lwl","2","1","5751","875121-403","000488294","116.0","05-15","Test This","Test 2","","Line4","Line5","Line6","Line7","Line8","Line9"


 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you explicitly calling "noteArray.get()" for each element? Do you think this is scalable if your noteArray grew to 1000 elements? or 1,000,000? You should use a loop instead. Then it's easy to put in a check to see what you get, and print the quotes or not as needed.
reply
    Bookmark Topic Watch Topic
  • New Topic