List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:com.alfaariss.oa.util.ModifiedBase64.java
/** * Encodes the supplied byte array./*from www . ja va 2 s . c o m*/ * * @param data byte array containing raw bytes * @param charset Charset used for encoding the byte array to a <tt>String</tt> * @return String Modified Base64 String representation * @throws UnsupportedEncodingException if supplied charset isn't supported */ public static String encode(byte[] data, String charset) throws UnsupportedEncodingException { byte[] baBase64 = Base64.encodeBase64(data); String sEncoded = new String(baBase64, charset); while (sEncoded.endsWith("=")) { sEncoded = sEncoded.substring(0, sEncoded.length() - 1); } sEncoded = sEncoded.replaceAll("\\+", "-"); sEncoded = sEncoded.replaceAll("/", "_"); return sEncoded; }
From source file:Main.java
public static boolean isPictureFormat(String imagePath) { boolean result = false; if (imagePath == null || "".equals(imagePath)) { result = false;//from w ww.j a v a 2 s .com } else if (imagePath.endsWith(".png") || imagePath.endsWith(".jpg") || imagePath.endsWith(".jpeg") || imagePath.endsWith(".bmp")) { result = true; } return result; }
From source file:edu.illinois.cs.cogcomp.bigdata.lucene.WikiURLAnalyzer.java
public static List<String> pruningTokenization(String s) { List<String> tokens = new ArrayList<String>(); String[] parts = StringUtils.split(s, replacement.charAt(0)); for (String part : parts) { if (!part.endsWith(".")) tokens.add(part);/* w ww . ja v a 2 s .c o m*/ } return tokens; }
From source file:Main.java
public static void addPluginIfMatches(File folderOrJar, String bundleName, Collection<File> result) { String name = folderOrJar.getName(); if (folderOrJar.isFile()) { if (name.equals(bundleName + ".jar") || name.startsWith(bundleName + "_") && name.endsWith(".jar")) result.add(folderOrJar);/*from www. ja va 2 s . c om*/ } else { if (name.equals(bundleName) || name.startsWith(bundleName + "_")) result.add(folderOrJar); } }
From source file:com.gargoylesoftware.htmlunit.general.HostExtractor.java
private static void fillMDNJavaScriptGlobalObjects(final WebClient webClient, final Set<String> set) throws Exception { final HtmlPage page = webClient .getPage("https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects"); for (final Object o : page.getByXPath("//*[name()='code']/text()")) { String value = o.toString(); if (!value.isEmpty()) { if (value.endsWith("()")) { value = value.substring(0, value.length() - 2); }// ww w . j a va 2 s .c o m set.add(value); } } }
From source file:com.lixiaocong.util.VideoFileHelper.java
public static List<File> findAllVideos(File file, String[] types) { List<File> ret = new LinkedList<>(); if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) for (File subFile : files) { List<File> subFiles = findAllVideos(subFile, types); ret.addAll(subFiles);/*from w ww . j a v a 2 s .c om*/ } } else { String name = file.getName(); for (String type : types) if (name.endsWith(type)) { ret.add(file); break; } } return ret; }
From source file:com.sap.prd.mobile.ios.mios.SCMUtil.java
private static String getDepotPath(String fullDepotPath) { if (fullDepotPath.endsWith(THREEDOTS)) { fullDepotPath = fullDepotPath.substring(0, fullDepotPath.length() - THREEDOTS.length()); }/*ww w . j a v a2 s .c o m*/ return fullDepotPath; }
From source file:edu.umn.msi.tropix.jobs.activities.factories.TestUtils.java
static <T extends TropixObjectDescription> T init(final T activityDescription) { init((ActivityDescription) activityDescription); activityDescription.setName(UUID.randomUUID().toString()); activityDescription.setDescription(UUID.randomUUID().toString()); activityDescription.setCommitted(RANDOM.nextBoolean()); try {/*w ww.ja va 2s . c o m*/ @SuppressWarnings("unchecked") final Map<String, Method> properties = BeanUtils.describe(activityDescription); for (final Map.Entry<String, Method> propertyEntry : properties.entrySet()) { final String property = propertyEntry.getKey(); if (property.endsWith("Id")) { final Object object = REFLECTION_HELPER.getBeanProperty(activityDescription, property); if (object == null) { REFLECTION_HELPER.setBeanProperty(activityDescription, property, UUID.randomUUID().toString()); } } } } catch (final Exception e) { throw new RuntimeException(e); } return activityDescription; }
From source file:Main.java
public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); // If we don't recognize the domain, throw an exception. if (!host.endsWith(".amazonaws.com")) { throw new IllegalArgumentException("Cannot parse the service name by an unrecognized endpoint(" + host + "). Please specify the service name by setEndpoint(String endpoint, String serviceName, String regionId)."); }/*from www .j a v a 2 s . co m*/ String serviceAndRegion = host.substring(0, host.indexOf(".amazonaws.com")); // S3 is different from other services, which supports virtual host and // use '-' as separator, the host may look like // 'bucketName.s3-us-west-2.amazonaws.com' if (serviceAndRegion.contains("s3-")) { return "s3"; } char separator = '.'; // If we don't detect a separator between service name and region, then // assume that the region is not included in the hostname, and it's only // the service name (ex: "http://iam.amazonaws.com"). if (serviceAndRegion.indexOf(separator) == -1) return serviceAndRegion; String service = serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); return service; }
From source file:org.n52.web.common.RequestUtils.java
/** * Get the request {@link URL} without the query parameter * * @return Request {@link URL} without query parameter * @throws IOException/*from w w w . j a va2 s.c o m*/ * @throws URISyntaxException */ public static String resolveQueryLessRequestUrl() throws IOException, URISyntaxException { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getRequest(); URL url = new URL(request.getRequestURL().toString()); String scheme = url.getProtocol(); String userInfo = url.getUserInfo(); String host = url.getHost(); int port = url.getPort(); String path = request.getRequestURI(); if (path != null && path.endsWith("/")) { path = path.substring(0, path.length() - 1); } URI uri = new URI(scheme, userInfo, host, port, path, null, null); return uri.toString(); }