File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "join list of strings" Watch "join list of strings" New topic

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?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195


[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)
I agree. Here's the link:
subject: join list of strings
It's not a secret anymore!