List of usage examples for java.lang String toString
public String toString()
From source file:$.FileUtils.java
public static String getFileNameFromUrl(String inputUrl) { String urlStr = inputUrl.toString(); String fileName = urlStr.substring(urlStr.lastIndexOf("/") + 1); return fileName; }//from w ww . j a va2 s.c om
From source file:eu.annocultor.analyzers.SolrPropertyHitsAnalyzer.java
static boolean hasWord(SolrDocument document, String fieldNamePrefix, String textToFind) { String[] wordsToFind = textToFind.toString().split("[\\W]+"); Set<String> docToLog = new HashSet<String>(); Set<String> queryToLog = new HashSet<String>(); for (String keyword : wordsToFind) { if (isLongEnoughToCount(keyword)) { queryToLog.add(keyword);/* ww w . j a v a2 s . c o m*/ for (String fieldName : document.getFieldNames()) { if (fieldName.startsWith(fieldNamePrefix)) { for (Object fieldValue : document.getFieldValues(fieldName)) { if (fieldValue != null) { for (String word : split(fieldValue)) { docToLog.add(word); if (StringUtils.equalsIgnoreCase(word, keyword)) { System.out.println( fieldNamePrefix + "-T: Q: " + StringUtils.join(queryToLog, ",") + "; doc: " + StringUtils.join(docToLog, ",")); return true; } } } } } } } } System.out.println(fieldNamePrefix + "-F: Q: " + StringUtils.join(queryToLog, ",") + "; doc: " + StringUtils.join(docToLog, ",")); return false; }
From source file:Main.java
public static String getSdCardPath() { // In this method,Lenovo pad return StorageDirectory,not "/mnt/sdcard1" String sdPath = null; if (checkSdCardIsExist()) { sdPath = Environment.getExternalStorageDirectory().getAbsolutePath(); }//from ww w . ja va2s . c om return sdPath.toString(); }
From source file:au.com.permeance.liferay.portlet.patchingtoolinfo.util.StringHelper.java
/** * Flattens a List of String items into a single String. * /*from w w w. ja v a 2 s . c om*/ * @param list input List of String items * @param itemSep list item seperator * @return flattened String with items separated by spaces */ public static String flattenStringList(List<String> list, String itemSep) { if (itemSep == null) { itemSep = StringPool.SPACE; } StringBuilder sb = new StringBuilder(); for (String item : list) { sb.append(item.toString()); sb.append(itemSep); } return sb.toString(); }
From source file:com.aerospike.examples.Main.java
/** * Write usage to console.// w w w . ja v a 2 s. c o m */ private static void logUsage(Options options) { HelpFormatter formatter = new HelpFormatter(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); String syntax = Main.class.getName() + " [<options>] all|(<example1> <example2> ...)"; formatter.printHelp(pw, 100, syntax, "options:", options, 0, 2, null); System.out.println(sw.toString()); System.out.println("examples:"); for (String name : ExampleNames) { System.out.println(name.toString()); } System.out.println(); System.out.println("All examples will be run if 'all' is specified as an example."); }
From source file:Main.java
/** *Valid plugin md5/*w ww . j a va 2 s . c o m*/ * @param path bundle archvie path * @param md5Sum target file md5 * @return if md5 matched,return true * ***/ public static boolean validFileMD5(String path, String md5Sum) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); File mFile = new File(path); if (mFile == null || !mFile.exists() || !mFile.isFile()) { return false; } FileInputStream in = new FileInputStream(mFile); FileChannel ch = in.getChannel(); MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0, mFile.length()); messageDigest.update(byteBuffer); String digest = String.format("%032x", new BigInteger(1, messageDigest.digest())); return md5Sum.equals(digest.toString()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { } return false; }
From source file:edu.sjsu.cohort6.esp.common.CommonUtils.java
/** * This method parses the generic jersey response to a generic JSONObject and singles out the "entity" piece * from the generic response.//from w w w. j a v a 2 s . com * * @param response * @return * @throws org.json.simple.parser.ParseException */ private static String getJsonFromResponse(Response response) throws org.json.simple.parser.ParseException { String c = response.readEntity(String.class); log.info(c.toString()); JSONParser parser = new JSONParser(); JSONObject json = (JSONObject) parser.parse(c); JSONObject jsonObject = (JSONObject) json.get("entity"); return jsonObject.toJSONString(); }
From source file:Main.java
/** * //from w ww .j ava 2 s .com * Get a valid xPath string to enable retrieval of an Element by attribute * name and its value. note that the full tag path must also be stated * * @param tagPath * example: /calls/step * @param attrName * example: ReportStepAttributes.STEP_NAME * @param attrValue * example: Call failed * * @return A valid xPath string */ public static String getXpathBasic(String tagPath, String attrName, String attrValue) { StringBuffer buf = new StringBuffer(); buf.append(tagPath); buf.append("["); buf.append("@"); buf.append(attrName.toString()); buf.append("="); buf.append("'"); buf.append(attrValue); buf.append("'"); buf.append("]"); // System.out.println("Xpath generated: " + (retStr = buf.toString())); return buf.toString(); }
From source file:edu.wright.daselab.linkgen.ConfigurationParams.java
private static void isConfigAvailable(String key, String value) { if ((value == null) || value.toString().trim().equals("")) { logger.error(Error.INVALID_CONFIG_PARAMS.toString() + " : " + key); Monitor.safeExit(Error.INVALID_CONFIG_PARAMS); }//from w ww .jav a 2s . co m }
From source file:ai.susi.json.JsonPath.java
private static void test(String json, String path) { JSONTokener tokener = new JSONTokener(json.trim()); JSONArray array = parse(tokener, path); System.out.println("json:" + json.toString()); System.out.println("path:" + path); System.out.println("pars:" + (array == null ? "NULL" : array.toString())); }