puchu
puchu

Reputation: 69

Inserting String in Relative path in Java

I have a path as below

    ConfigFactory oConfig = new ConfigFactory(sBaseUrl,
                "abc",
                "12345",
         "/u/toy/apps/JETTY/instances/US_32970_test/pop-mm_3.0.201/config"
                );

32970 in the above path should come from String Queue = "32930"

How can i append value of Queue in the path

Upvotes: 0

Views: 43

Answers (2)

FLP
FLP

Reputation: 2047

Concat the String:

"/u/toy/apps/JETTY/instances/US_" + Queue + "_test/pop-mm_3.0.201/config"

Upvotes: 0

Andy Turner
Andy Turner

Reputation: 140319

Use String.format(String, Object...):

String.format(
    "/u/toy/apps/JETTY/instances/US_%s_test/pop-mm_3.0.201/config",
    Queue)

Upvotes: 4

Related Questions