提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
返回一个字符串,该字符串代表预期包含指定对象源代码的文件名。
//package com.nowjava; public class Main { /** NowJava.com - 时 代 Java 提供 **/ public static void main(String[] argv) { Object object = "nowjava.com"; System.out.println(objectToSourceFileName(object)); } /** Return a string representing the name of the file expected to * contain the source code for the specified object. This method * simply replaces "." with "/" and appends ".java" to the class * name. * @param object The object. * @return The expected source file name. */ public static String objectToSourceFileName(Object object) { String sourceFileNameBase = object.getClass().getName() .replace('.', '/');/**来 自 N o w J a v a . c o m**/ // Inner classes: Get rid of everything past the first $ if (sourceFileNameBase.indexOf("$") != -1) { sourceFil