List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:com.alliander.osgp.adapter.protocol.iec61850.device.FirmwareLocation.java
private static String cleanUpPath(final String path) { String cleanPath = path; while (cleanPath.endsWith("/")) { cleanPath = cleanPath.substring(0, cleanPath.length() - 1); }/*from w ww. ja v a 2s. c o m*/ while (cleanPath.startsWith("/")) { cleanPath = cleanPath.substring(1); } return cleanPath; }
From source file:com.concursive.connect.scheduler.ScheduledJobs.java
/** * Scans the jobs path for the given ServletContext * * @param scheduler/*ww w . j av a2 s . c o m*/ * @param context * @throws SchedulerException */ public static void addJobs(Scheduler scheduler, ServletContext context) throws SchedulerException { // Determine the ApplicationPrefs ApplicationPrefs prefs = (ApplicationPrefs) scheduler.getContext().get("ApplicationPrefs"); // Find job files in the jobs path Set<String> jobFiles = context.getResourcePaths("/WEB-INF/jobs/"); if (jobFiles != null && jobFiles.size() > 0) { for (String thisFile : jobFiles) { if (thisFile.endsWith(".xml")) { try { LOG.debug("Adding jobs from... " + thisFile); QuartzUtils.addJobs(scheduler, context.getResource(thisFile), prefs.getPrefs()); } catch (Exception e) { LOG.error("addJobs exception", e); } } } } }
From source file:edu.cmu.cs.lti.ark.util.SerializedObjects.java
public static InputStream getInputStream(String inputFile) throws IOException { if (inputFile.endsWith(".gz")) { return new GZIPInputStream(new FileInputStream(inputFile)); } else {/* ww w . j av a2s .c o m*/ return new FileInputStream(inputFile); } }
From source file:edu.harvard.i2b2.ontology.util.StringUtil.java
public static String getSymbol(String key) { if (key.endsWith("\\")) { key = key.substring(0, key.length() - 1).trim(); }/*w w w . ja v a 2s. c o m*/ int end = key.lastIndexOf("\\"); String symbol = key.substring(end + 1, key.length()).trim(); return symbol; }
From source file:Main.java
@SuppressLint("DefaultLocale") public static String findSuffix(String path, String[] ss) { path = path.toLowerCase();/*from w ww.ja va 2 s. c o m*/ for (int i = 0, len = ss.length; i < len; i++) { if (path.endsWith(ss[i].toLowerCase())) { return ss[i]; } } return null; }
From source file:Main.java
static File makeTempJar(File moduleFile) throws IOException { String prefix = moduleFile.getName(); if (prefix.endsWith(".jar") || prefix.endsWith(".JAR")) { // NOI18N prefix = prefix.substring(0, prefix.length() - 4); }// w ww.j av a2s . com if (prefix.length() < 3) prefix += '.'; if (prefix.length() < 3) prefix += '.'; if (prefix.length() < 3) prefix += '.'; String suffix = "-test.jar"; // NOI18N File physicalModuleFile = File.createTempFile(prefix, suffix); physicalModuleFile.deleteOnExit(); InputStream is = new FileInputStream(moduleFile); try { OutputStream os = new FileOutputStream(physicalModuleFile); try { byte[] buf = new byte[4096]; int i; while ((i = is.read(buf)) != -1) { os.write(buf, 0, i); } } finally { os.close(); } } finally { is.close(); } return physicalModuleFile; }
From source file:Main.java
/** * opens a FileChooser to select a file or folder if a folder is selected a * default filename is appended/* w ww . j ava2 s .c o m*/ * * @param c parent * @param fileName default file name (in case a folder is selected) * @return null if nothing got selected, otherwise the absolute path */ @SuppressWarnings("SameParameterValue") public static String openFileOrDirectoryWithDefaultFileName(Component c, File currentDirectory, String fileName) { File file = openJFileChooser(c, currentDirectory, JFileChooser.FILES_AND_DIRECTORIES, null); if (file == null) { return null; } String path = file.getAbsolutePath(); if (file.isDirectory()) { if (path.endsWith(File.separator)) { path = path + fileName; } else { path = path + File.separator + fileName; } } return path; }
From source file:com.mysoft.b2b.event.scheduler.protocol.rmi.RMIClientHelper.java
public static ProtocolService getRMIProtocolService(String protocolUrl) { String serviceUrl = ""; if (protocolUrl != null && protocolUrl.endsWith("/")) { serviceUrl = protocolUrl;/*from ww w. j a v a2 s . c om*/ } else { serviceUrl = protocolUrl + "/"; } serviceUrl = serviceUrl + ProtocolService.class.getSimpleName(); RmiProxyFactoryBean rpfb = new RmiProxyFactoryBean(); rpfb.setServiceUrl(serviceUrl); rpfb.setServiceInterface(ProtocolService.class); try { rpfb.setLookupStubOnStartup(false); rpfb.setRefreshStubOnConnectFailure(true); rpfb.afterPropertiesSet(); } catch (Exception e) { logger.info("Can't get the remote RMI server: " + serviceUrl + ", because " + e.getMessage()); return null; } logger.info("Success to init RMI local proxy service for " + serviceUrl); return (ProtocolService) rpfb.getObject(); }
From source file:DBMS.UpdateFileUpload.java
public static boolean processFile(String path, FileItemStream item, int id) { try {// ww w . j a va2 s . c o m String check = item.getName(); if (check.endsWith(".jpg") || check.endsWith(".JPG")) { String imstring = "images/" + Integer.toString(id); File f = new File(path + File.separator + imstring); if (!f.exists()) f.mkdir(); File savedFile = new File(f.getAbsolutePath() + File.separator + item.getName()); FileOutputStream fos = new FileOutputStream(savedFile); InputStream is = item.openStream(); int x = 0; byte[] b = new byte[1024]; while ((x = is.read(b)) != -1) { fos.write(b, 0, x); } fos.flush(); fos.close(); String dbimage = imstring + "/a.jpg"; //dc.enterImage(dbimage); //im =dbimage; //System.out.println("Resizing!"); //Resize rz = new Resize(); //rz.resize(dbimage); BufferedImage originalImage = ImageIO.read(savedFile); int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImageJpg = resizeImage(originalImage, type); ImageIO.write(resizeImageJpg, "jpg", savedFile); File rFile = new File(f.getAbsolutePath() + "/a.jpg"); savedFile.renameTo(rFile); ProfileEditDB dc = new ProfileEditDB(); dc.enterImage(id, dbimage); System.out.println("Link Entered to Database!"); return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:io.inkstand.scribble.rules.ZipAssert.java
/** * Verifies if a folder with the specified path exists * @param zf/* w w w . j a v a2 s.co m*/ * the zip file to search for the entry * @param entryPath * the path to the folder entry. Note that it is required that the path ends with '/' otherwise it can't * be recognized as a directory, even though the entry may be found with the trailing slash */ public static void assertZipFolderExists(final ZipFile zf, final String entryPath) { final String folderPath; if (entryPath.endsWith("/")) { folderPath = entryPath; } else { folderPath = entryPath + '/'; } final ZipEntry entry = zf.getEntry(folderPath); assertNotNull("Entry " + folderPath + " does not exist", entry); assertTrue("Entry " + folderPath + " is no folder", entry.isDirectory()); }