public static File classToRelativePackagePath ( Class < ? > clazz ) { if ( File . separator . equals ( "/" ) ) { return new File ( clazz . getName ( ) . replaceAll ( "\\." , File . separator ) + ".java" ) ; } else { return new File ( clazz . getName ( ) . replaceAll ( "\\." , File . separator + File . separator ) + ".java" ) ; } }
This method converts a Class into a File which contains the package path . This is used to access Jar contents or the content of source directories to find source or class files .