提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
如果给定资源是zip,jar或war文件,则返回true。
/** * 时 代 J a v a - nowjava.com 提 供 **/ //Licensed under the Apache License, Version 2.0 (the "License"); //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { String resource = "nowjava.com"; System.out.println(isSupported(resource)); } /** * The suffixes of the files to support. */ public static final String[] SUPPORTED_FILES = new String[] { ".zip", ".jar", ".war" }; /** * Returns true if the given {@code resource} is either a zip, jar or war file. */ public static boolean isSupported(String resource) { int idx = resource.lastIndexOf('.'); if (resource.length() == idx + 4) { for (int i = 0; i < SUPPORTED_FILE