Here you can find the source of pathToPackageName(String relativeFileName, boolean leadingDot)
public static String pathToPackageName(String relativeFileName, boolean leadingDot)
//package com.java2s; //License from project: Apache License public class Main { public static String pathToPackageName(String relativeFileName, boolean leadingDot) { return (!leadingDot && relativeFileName.startsWith("/") ? relativeFileName.substring(1) : relativeFileName) .replaceAll("/", "."); }/*w w w .j a va2 s . c o m*/ }