• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

remove characters from ArrayList

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am new to Java. I have an arraylist as below and trying to write the same array to a csv file. While writing the characters [ and ] also written in the csv file. How to remove those characters Or is there anyother way to write into csv.

[AJAY.UPPALURI,InActive,Active,InActive,2018-01-03 00:00:00.0]
[AJAYVEER.SINGH,InActive,Active,InActive,2018-01-03 00:00:00.0]

Below is the code

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, make sure that there are no '[' or ']' in tempmap that are being written into the ArrayList.

If there are none, you could try using the ArrayList.Remove(object o ) method, which would remove the first occurrence of the brackets, or the RemoveAll method, which removes all occurrences. Since the Remove method returns a boolean, you could easily test to see if it is working or not.


 
Saloon Keeper
Posts: 6925
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of
Use
And then concatenate the strings using
And output
 
Kiran Er
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it worked
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!