转:https://www.liangzl.com/get-article-detail-39961.html
要用replaceAll()方法,而不是replace();
包名中的"."在正则中匹配时,要转义\.,.在正则表达式中匹配任意一个字符;
windows下File.separator为\,需要Matcher.quoteReplacement(File.separator)获取。
String path = packageName.replaceAll("\.", Matcher.quoteReplacement(File.separator));