List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:Main.java
public static ArrayList<String> retrieveLinks(String text) { ArrayList<String> links = new ArrayList<String>(); String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(text);/* ww w .j a va 2s . c o m*/ while (m.find()) { String urlStr = m.group(); if (urlStr.startsWith("(") && urlStr.endsWith(")")) { char[] stringArray = urlStr.toCharArray(); char[] newArray = new char[stringArray.length - 2]; System.arraycopy(stringArray, 1, newArray, 0, stringArray.length - 2); urlStr = new String(newArray); System.out.println("Finally Url =" + newArray.toString()); } System.out.println("...Url..." + urlStr); links.add(urlStr); } return links; }
From source file:org.awesomeagile.webapp.security.google.GoogleConfigurableOAuth2Template.java
private static String end(String base, String path) { if (!base.endsWith(SEPARATOR)) { base += SEPARATOR;/*from ww w .j av a2 s . com*/ } return base + path; }
From source file:cf.janga.hook.utils.IOUtils.java
public static boolean hasExtension(File file, String extension) { String fileName = file.getName(); return StringUtils.isNotBlank(fileName) && fileName.endsWith("." + extension) && file.isFile(); }
From source file:com.buddycloud.channeldirectory.commons.db.CreateSchema.java
private static void runScript(ChannelDirectoryDataSource channelDirectoryDataSource, String sqlFile) throws IOException, FileNotFoundException, SQLException { List<String> readLines = IOUtils.readLines(new FileInputStream(sqlFile)); Connection connection = channelDirectoryDataSource.getConnection(); StringBuilder statementStr = new StringBuilder(); for (String line : readLines) { statementStr.append(line);//from ww w .j a va2 s . c o m if (line.endsWith(SQL_DELIMITER)) { Statement statement = connection.createStatement(); statement.execute(statementStr.toString()); statement.close(); statementStr.setLength(0); } } connection.close(); }
From source file:Main.java
public static List<String> getDatabaseList(Context context) { String[] strDatabaseList = context.databaseList(); List<String> list = new ArrayList<>(); if (strDatabaseList != null) { for (String name : strDatabaseList) { if (name.startsWith(DATABASE_START) && name.endsWith(DATABASE_TYPE)) { list.add(name.substring(0, name.length() - DATABASE_TYPE.length())); }/* w w w. java 2 s. c o m*/ } } return list; }
From source file:Main.java
private static void recurse(List<Class<?>> classes, String packageName, Class<? extends Annotation> a) throws ClassNotFoundException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); String path = packageName.replace('.', '/'); URL resource = loader.getResource(path); if (resource != null) { String filePath = resource.getFile(); if (filePath != null && new File(filePath).isDirectory()) { for (String file : new File(filePath).list()) { if (file.endsWith(".class")) { String name = packageName + '.' + file.substring(0, file.indexOf(".class")); Class<?> clazz = Class.forName(name); if (clazz.isAnnotationPresent(a)) classes.add(clazz); } else if (new File(filePath, file).isDirectory()) { recurse(classes, packageName + "." + file, a); }/* w w w .j a v a2 s.c o m*/ } } } }
From source file:Main.java
public static String perfectSurround(String str, String attach) { if (str == null) { return attach; }/* www . j a va2s . c om*/ str = str.endsWith(attach) ? str : (str + attach); str = str.startsWith(attach) ? str : (attach + str); return str; }
From source file:Main.java
public static String makePath(String path, String name) { String str1 = File.separator; String p = ""; if (path.endsWith(str1)) { p = path + name;/* www. j a v a 2 s .c om*/ } else { p = path + str1 + name; } return p; }
From source file:Main.java
public static String removeQuotationsInCurrentSSIDForJellyBean(String ssid) { if (Build.VERSION.SDK_INT >= 17 && ssid != null && ssid.startsWith("\"") && ssid.endsWith("\"")) ssid = ssid.substring(1, ssid.length() - 1); return ssid;//from w ww.j a v a 2 s . c o m }
From source file:Main.java
public static File saveImageFile(Component parent) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileFilter(new FileFilter() { @Override//from w ww . jav a 2s.c o m public String getDescription() { return "bmp"; } @Override public boolean accept(File f) { String name = f.getName(); boolean accepted = f.isDirectory() || name.endsWith(".bmp"); return accepted; } }); fileChooser.showSaveDialog(parent); return fileChooser.getSelectedFile(); }