List of usage examples for org.apache.commons.lang3 StringUtils strip
public static String strip(final String str)
Strips whitespace from the start and end of a String.
This is similar to #trim(String) but removes whitespace.
From source file:com.wxine.android.model.Community.java
public Set<String> getFriends() { try {/*from www.j a va 2 s . com*/ String[] array = friend.split(","); for (String a : array) { if (StringUtils.isNotBlank(a)) { friends.add(StringUtils.trim(StringUtils.strip(a))); } } } catch (Exception e) { } return friends; }
From source file:com.eryansky.service.sys.DictionaryTypeManager.java
/** * ???name./*from w w w . j av a 2 s .c o m*/ * * @param name * ??? * @return * @throws DaoException * @throws SystemException * @throws ServiceException */ @SuppressWarnings("unchecked") public DictionaryType getByName(String name) throws DaoException, SystemException, ServiceException { if (StringUtils.isBlank(name)) { return null; } name = StringUtils.strip(name);// List<DictionaryType> list = dictionaryTypeDao .createQuery("from DictionaryType d where d.name = ?", new Object[] { name }).list(); return list.isEmpty() ? null : list.get(0); }
From source file:com.google.mr4c.config.execution.DirectoryConfig.java
private static List<String> loadList(Properties props, String name) { String data = props.getProperty(name); if (data == null) { throw new IllegalArgumentException("Missing " + name); }// w w w. ja v a 2 s. c o m data = StringUtils.strip(data); if (StringUtils.isEmpty(data)) { return Collections.emptyList(); } String[] vals = StringUtils.split(data, ", "); return Arrays.asList(vals); }
From source file:fr.noop.subtitle.stl.StlParser.java
private String readString(DataInputStream dis, int length) throws IOException { byte[] bytes = new byte[length]; dis.readFully(bytes, 0, length);//from w w w . j av a 2 s . c om // Remove spaces at start and end of the string return StringUtils.strip(new String(bytes)); }
From source file:com.eryansky.service.sys.DictionaryManager.java
/** * ??code.// w w w . java 2 s.c om * * @param code * ?? * @return * @throws DaoException * @throws SystemException * @throws ServiceException */ @SuppressWarnings("unchecked") public Dictionary getByCode(String code) throws DaoException, SystemException, ServiceException { if (StringUtils.isBlank(code)) { return null; } code = StringUtils.strip(code);// List<Dictionary> list = dictionaryDao .createQuery("from Dictionary d where d.code = ?", new Object[] { code }).list(); return list.isEmpty() ? null : list.get(0); }
From source file:com.wxine.android.model.Community.java
public Set<String> getTopics() { try {/*ww w . j a v a 2 s .com*/ String[] array = topic.split(","); for (String a : array) { if (StringUtils.isNotBlank(a)) { topics.add(StringUtils.trim(StringUtils.strip(a))); } } } catch (Exception e) { } return topics; }
From source file:ch.cyberduck.cli.TerminalPreferences.java
@Override protected void setDefaults() { super.setDefaults(); defaults.put("website.home", "http://duck.sh/"); defaults.put("website.help", "http://help.duck.sh/"); System.setProperty("jna.library.path", this.getProperty("java.library.path")); switch (Factory.Platform.getDefault()) { case mac: {//from w w w . ja v a 2 s . co m break; } case windows: { break; } case linux: { try { final Process echo = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "echo ~" }); defaults.put("local.user.home", StringUtils.strip(IOUtils.toString(echo.getInputStream(), Charset.defaultCharset()))); } catch (IOException e) { log.warn("Failure determining user home with `echo ~`"); } defaults.put("ssh.authentication.agent.enable", String.valueOf(false)); // Lowercase folder names to use when looking for profiles and bookmarks in user support directory defaults.put("bookmarks.folder.name", "bookmarks"); defaults.put("profiles.folder.name", "profiles"); defaults.put("connection.ssl.securerandom", "NativePRNGNonBlocking"); break; } } defaults.put("local.normalize.prefix", String.valueOf(true)); defaults.put("connection.login.name", System.getProperty("user.name")); // Disable transfer filters defaults.put("queue.download.skip.enable", "false"); defaults.put("queue.upload.skip.enable", "false"); defaults.put("queue.copy.action", TransferAction.comparison.name()); defaults.put("queue.copy.reload.action", TransferAction.comparison.name()); }
From source file:ctrus.pa.bow.java.JavaFileTokenizer.java
private StringBuffer _preProcessSourceText(List<String> sourceTextLines) { StringBuffer javaSourceTextBuffer = new StringBuffer(); boolean commentMarked = false; for (String line : sourceTextLines) { String stripedLine = StringUtils.strip(line); if (stripedLine.startsWith("//")) { javaSourceTextBuffer.append("/* ").append(stripedLine); commentMarked = true;/*w w w . j a v a 2s . c om*/ } else { if (commentMarked) { javaSourceTextBuffer.append("*/ ").append(stripedLine); commentMarked = false; } else { javaSourceTextBuffer.append(stripedLine); } } javaSourceTextBuffer.append("\n"); } return javaSourceTextBuffer; }
From source file:ca.phon.media.FFMpegMediaExporter.java
private List<String> getCmdLine() { List<String> cmdLine = new ArrayList<String>(); cmdLine.add(getFFMpegBinary());/*from ww w . j ava 2 s.co m*/ // setup options cmdLine.add("-i"); cmdLine.add(inputFile); if (startTime >= 0L) { cmdLine.add("-ss"); cmdLine.add("" + (startTime / 1000.0f)); } if (duration > 0L) { cmdLine.add("-t"); cmdLine.add("" + (duration / 1000.0f)); } if (isIncludeAudio()) { String ac = getAudioCodec(); if (ac.equalsIgnoreCase("wav") || ac.equalsIgnoreCase("raw")) { ac = "pcm_s16le"; } cmdLine.add("-acodec"); cmdLine.add(ac); } else { cmdLine.add("-an"); } if (isIncludeVideo()) { cmdLine.add("-vcodec"); cmdLine.add(getAudioCodec()); } else { cmdLine.add("-vn"); } if (StringUtils.strip(additionalArgs).length() > 0) { BufferedReader argsReader = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(additionalArgs.getBytes()))); String line = null; try { while ((line = argsReader.readLine()) != null) { if (StringUtils.strip(line).length() == 0 || line.matches("^#.*")) { continue; } // allow for a single pair of arguments to be added // for example -ac 1 // otherwise it's one argument per line int spaceIdx = line.indexOf(" "); if (spaceIdx > 0) { String arg1 = line.substring(0, spaceIdx); String arg2 = line.substring(spaceIdx + 1); cmdLine.add(arg1); cmdLine.add(arg2); } else cmdLine.add(StringUtils.strip(line)); } argsReader.close(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } cmdLine.add("-y"); cmdLine.add(outputFile); return cmdLine; }
From source file:com.wxine.android.model.Community.java
public Set<String> getTags() { try {//from ww w . jav a 2 s. c om String[] array = tag.split(","); for (String a : array) { if (StringUtils.isNotBlank(a)) { tags.add(StringUtils.trim(StringUtils.strip(a))); } } } catch (Exception e) { } return tags; }