Java tutorial
//package com.java2s; public class Main { private static String removeSlashInStartAndAddAtTheEndOfBaseDir(String baseDir) { baseDir = baseDir.endsWith("/") ? baseDir : baseDir + "/"; while (baseDir.startsWith("/") || baseDir.startsWith("./")) { baseDir = baseDir.startsWith("/") ? baseDir.substring(1) : baseDir; baseDir = baseDir.startsWith("./") ? baseDir.substring(2) : baseDir; } return baseDir; } }