/**  
* <p>Title: TestFanShe.java</p>  
* <p>Description: </p>  
* <p>Company: www.treebear.cn</p>  
* @author chong.du  
* @date 2018年5月16日  
* @version 1.0  
*/
package test.fanshe;

import java.io.File;
import java.net.URL;
import java.util.Enumeration;

import org.junit.Test;


public class TestFanShe {

	@Test
	public void test() throws Exception {
		
		//包名
		String packageName = "test.fanshe";
		
		Enumeration<URL> urls = TestFanShe.class.getClassLoader().getResources(packageName.replace(".", "/"));

		while (urls.hasMoreElements()) {
			
			URL url = (URL) urls.nextElement();

			if ("file".equals(url.getProtocol())) {
				String realPath = url.getFile();

				File file = new File(realPath);
				if (file.exists()) {

					File[] files = file.listFiles();
					for (File f : files) {
						System.out.println(f.getName());

					}
				}
			}
		}
	}

}

  

相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-07-27
  • 2020-12-17
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
猜你喜欢
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2021-08-28
  • 2022-02-03
  • 2022-12-23
相关资源
相似解决方案