ProjectPackagesPrinter

本文通过Java程序展示了Spring框架的包结构,从根目录开始遍历所有子包,并统计了包的数量。该程序使用递归方式深入每个子目录,打印出完整的包路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import java.io.File;

/**  
 * @author Dao
 *   
 */
public class ProjectPackagesPrinter
{
  private static int packageNumber = 0;
  /**  
   * @param args  
   */
  public static void main(String[] args)
  {
    String packageBasePath = "G:\\spring\\spring-framework-2.5\\src\\main\\java\\org";
    
    File file = new File(packageBasePath);
    
    showPackage(file, "");
    
    System.out.println("Total package: " + packageNumber);
  }
  
  private static void showPackage(File file, String basePath)
  {
    if (file.isDirectory())
    {
      packageNumber++;
      
      String directoryName = file.getName();
      String packagePath = basePath + directoryName;
      
      System.out.println(packagePath);
      
      File[] subFiles = file.listFiles();
      
      for (File subFile : subFiles)
      {
        showPackage(subFile, packagePath + ".");
      }
    }
  }
}

 效果

org.springframework
org.springframework.aop
org.springframework.aop.aspectj
org.springframework.aop.aspectj.autoproxy
org.springframework.aop.config
org.springframework.aop.framework
org.springframework.aop.framework.adapter
org.springframework.aop.framework.autoproxy
org.springframework.aop.framework.autoproxy.target
org.springframework.aop.interceptor
org.springframework.aop.scope
org.springframework.aop.support
org.springframework.aop.target
org.springframework.aop.target.dynamic
org.springframework.beans
org.springframework.beans.factory
org.springframework.beans.factory.access
org.springframework.beans.factory.config
org.springframework.beans.factory.parsing
org.springframework.beans.factory.support
org.springframework.beans.factory.wiring
org.springframework.beans.factory.xml
org.springframework.beans.propertyeditors
org.springframework.beans.support
org.springframework.cache
org.springframework.cache.ehcache
org.springframework.context
org.springframework.context.access
org.springframework.context.config
org.springframework.context.event
org.springframework.context.i18n
org.springframework.context.support
org.springframework.core
org.springframework.core.enums
org.springframework.core.io
org.springframework.core.io.support
org.springframework.core.style
org.springframework.core.task
org.springframework.core.task.support
org.springframework.dao
org.springframework.dao.support
org.springframework.ejb
org.springframework.ejb.access
org.springframework.ejb.config
org.springframework.ejb.support
org.springframework.jca
org.springframework.jca.cci
org.springframework.jca.cci.connection
org.springframework.jca.cci.core
org.springframework.jca.cci.core.support
org.springframework.jca.cci.object
org.springframework.jca.context
org.springframework.jca.endpoint
org.springframework.jca.support
org.springframework.jca.work
org.springframework.jdbc
org.springframework.jdbc.core
org.springframework.jdbc.core.namedparam
org.springframework.jdbc.core.support
org.springframework.jdbc.datasource
org.springframework.jdbc.datasource.lookup
org.springframework.jdbc.object
org.springframework.jdbc.support
org.springframework.jdbc.support.incrementer
org.springframework.jdbc.support.lob
org.springframework.jdbc.support.nativejdbc
org.springframework.jdbc.support.rowset
org.springframework.jms
org.springframework.jms.config
org.springframework.jms.connection
org.springframework.jms.core
org.springframework.jms.core.support
org.springframework.jms.listener
org.springframework.jms.listener.adapter
org.springframework.jms.listener.endpoint
org.springframework.jms.listener.serversession
org.springframework.jms.remoting
org.springframework.jms.support
org.springframework.jms.support.converter
org.springframework.jms.support.destination
org.springframework.jmx
org.springframework.jmx.access
org.springframework.jmx.export
org.springframework.jmx.export.assembler
org.springframework.jmx.export.metadata
org.springframework.jmx.export.naming
org.springframework.jmx.export.notification
org.springframework.jmx.support
org.springframework.jndi
org.springframework.jndi.support
org.springframework.mail
org.springframework.mail.javamail
org.springframework.metadata
org.springframework.metadata.commons
org.springframework.orm
org.springframework.orm.hibernate3
org.springframework.orm.hibernate3.support
org.springframework.orm.ibatis
org.springframework.orm.ibatis.support
org.springframework.orm.jdo
org.springframework.orm.jdo.support
org.springframework.orm.toplink
org.springframework.orm.toplink.support
org.springframework.remoting
org.springframework.remoting.caucho
org.springframework.remoting.httpinvoker
org.springframework.remoting.jaxrpc
org.springframework.remoting.jaxrpc.support
org.springframework.remoting.rmi
org.springframework.remoting.soap
org.springframework.remoting.support
org.springframework.scheduling
org.springframework.scheduling.backportconcurrent
org.springframework.scheduling.commonj
org.springframework.scheduling.quartz
org.springframework.scheduling.support
org.springframework.scheduling.timer
org.springframework.scripting
org.springframework.scripting.bsh
org.springframework.scripting.config
org.springframework.scripting.groovy
org.springframework.scripting.jruby
org.springframework.scripting.support
org.springframework.transaction
org.springframework.transaction.config
org.springframework.transaction.interceptor
org.springframework.transaction.jta
org.springframework.transaction.support
org.springframework.ui
org.springframework.ui.context
org.springframework.ui.context.support
org.springframework.ui.freemarker
org.springframework.ui.jasperreports
org.springframework.ui.velocity
org.springframework.util
org.springframework.util.comparator
org.springframework.util.xml
org.springframework.validation
org.springframework.web
org.springframework.web.bind
org.springframework.web.bind.support
org.springframework.web.context
org.springframework.web.context.request
org.springframework.web.context.support
org.springframework.web.filter
org.springframework.web.jsf
org.springframework.web.multipart
org.springframework.web.multipart.commons
org.springframework.web.multipart.support
org.springframework.web.portlet
org.springframework.web.portlet.bind
org.springframework.web.portlet.context
org.springframework.web.portlet.handler
org.springframework.web.portlet.multipart
org.springframework.web.portlet.mvc
org.springframework.web.portlet.util
org.springframework.web.servlet
org.springframework.web.servlet.handler
org.springframework.web.servlet.handler.metadata
org.springframework.web.servlet.i18n
org.springframework.web.servlet.mvc
org.springframework.web.servlet.mvc.multiaction
org.springframework.web.servlet.mvc.support
org.springframework.web.servlet.mvc.throwaway
org.springframework.web.servlet.support
org.springframework.web.servlet.tags
org.springframework.web.servlet.tags.form
org.springframework.web.servlet.theme
org.springframework.web.servlet.view
org.springframework.web.servlet.view.document
org.springframework.web.servlet.view.freemarker
org.springframework.web.servlet.view.jasperreports
org.springframework.web.servlet.view.tiles
org.springframework.web.servlet.view.velocity
org.springframework.web.servlet.view.xslt
org.springframework.web.struts
org.springframework.web.util

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值