Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes join list of strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "join list of strings" Watch "join list of strings" New topic
Author

join list of strings

lajos kamocsay
Ranch Hand

Joined: Aug 12, 2006
Posts: 37
Is there an easy way to join a list of string in java using a delimiter?
For example:



I would like to make that into a path string, "/home/joe/tmp/". I can do:



But it seems there should be something in the API to do this ain one step. Python has:



Anything like that in Java?


Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

No.


[Jess in Action][AskingGoodQuestions]
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
No, but you could write one fairly easily using varargs in 1.5:



Usage: join("/", "home", "joe", "tmp)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: join list of strings
 
Similar Threads
How to pass a dynamic parameter in struts-config.xml?
Listing all directories from a given root in batch file
Different reults of execution of jar from terminal and by double clicking
large system.in to object concurrent operations
NullPointerException Just Does Not Make Sense