Here you can find the source of getResourceScripts(String path)
Parameter | Description |
---|---|
path | the path |
Parameter | Description |
---|---|
IOException | Signals that an I/O exception has occurred. |
public static Collection<String> getResourceScripts(String path) throws IOException
//package com.java2s; /**//from w ww. j a v a 2 s . c o m * Copyright (c) 2016 TermMed SA * Organization * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/ */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { /** * Gets the resource scripts. * * @param path the path * @return the resource scripts * @throws IOException Signals that an I/O exception has occurred. */ public static Collection<String> getResourceScripts(String path) throws IOException { System.out.println("getting files from " + path); List<String> strFiles = new ArrayList<String>(); // InputStream is=ResourceUtils.class.getResourceAsStream("/" + path); // InputStreamReader risr = new InputStreamReader(is); // BufferedReader br=new BufferedReader(risr); // String line; // while((line=br.readLine())!=null){ // strFiles.add(line); // } String file = null; if (new File("stats-gen.jar").exists()) { file = "stats-gen.jar"; } else { file = "target/stats-gen.jar"; } ZipInputStream zip = new ZipInputStream(new FileInputStream(file)); while (true) { ZipEntry e = zip.getNextEntry(); if (e == null) break; String name = e.getName(); if (name.startsWith(path) && !name.endsWith("/")) { // if (!name.startsWith("/")){ // name="/" + name; // } strFiles.add(name); } } System.out.println("files:" + strFiles.toString()); return strFiles; } }