Consider this code:
string xx = "/test/file2/".Trim('/');
Console.WriteLine(xx);
Console.Read();
This code returns test/file2. What is an efficient way to do this in Java?
Consider this code:
string xx = "/test/file2/".Trim('/');
Console.WriteLine(xx);
Console.Read();
This code returns test/file2. What is an efficient way to do this in Java?
 
    
    Here is how to do the same in Java:
 String xx = "/test/file2/".replaceAll("(^/*|/*$)", "");
This uses a regex that matches multiple / from the beginning or multiple / at the end and replaces them with void.
