Example usage for java.lang String toString

List of usage examples for java.lang String toString

Introduction

In this page you can find the example usage for java.lang String toString.

Prototype

public String toString() 

Source Link

Document

This object (which is already a string!) is itself returned.

Usage

From source file:com.p5solutions.core.utils.NumberUtils.java

public static boolean isInteger(String value) {
    if (isNatural(value)) {
        Long v = NumberUtils.valueOf(value.toString(), Long.class);
        if (v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE) {
            return true;
        }/*from w ww . j  av  a  2  s .  co  m*/
    }
    return false;
}

From source file:com.p5solutions.core.utils.NumberUtils.java

public static boolean isLong(String value) {
    if (isNatural(value)) {
        Long v = NumberUtils.valueOf(value.toString(), Long.class);
        if (v >= Long.MIN_VALUE && v <= Long.MAX_VALUE) {
            return true;
        }/* w ww  .j a  va 2s  .  c  o  m*/
    }
    return false;
}

From source file:com.oneapm.base.tools.UrlPostMethod.java

public static String urlGetMethod(String url) {
    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
    HttpGet get = new HttpGet(url);
    HttpEntity entity = null;/*from   w  ww. j  a  v a  2s . co  m*/
    String json = null;
    try {
        CloseableHttpResponse response = httpClient.execute(get);
        json = EntityUtils.toString(response.getEntity(), "UTF-8");
    } catch (IOException e) {
        e.printStackTrace();
    }
    return json.toString();

}

From source file:com.collective.celos.Util.java

public static String augmentHdfsPath(String hdfsPrefix, String path) throws URISyntaxException {

    if (hdfsPrefix.isEmpty() || hdfsPrefix.equals("/")) {
        return path;
    }//from  w ww. j a  v  a  2 s.c om

    for (String ch : conversions.keySet()) {
        path = path.replace(ch.toString(), conversions.get(ch).toString());
    }
    URI oldUri = URI.create(path);

    String host = oldUri.getHost();
    if (oldUri.getRawSchemeSpecificPart().startsWith("///") && host == null) {
        host = "";
    }

    URI newUri = new URI(oldUri.getScheme(), oldUri.getUserInfo(), host, oldUri.getPort(),
            hdfsPrefix + oldUri.getPath(), oldUri.getQuery(), oldUri.getFragment());
    path = newUri.toString();
    for (String ch : backConversions.keySet()) {
        path = path.replace(ch.toString(), backConversions.get(ch).toString());
    }
    return path;
}

From source file:com.alkacon.opencms.commons.CmsStringCrypter.java

/**
 * Converts the given password to machine readable form.<p>
 * //ww  w .jav a  2  s  . c o m
 * @param password the password to convert to a machine readable key
 * @return the password in machine readable form
 */
private static byte[] getKey(String password) {

    try {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(password.toString().getBytes());
        byte[] key = md5.digest();
        // now get the first 8 bytes
        byte[] finalKey = new byte[8];
        for (int i = 0; i <= 7; i++) {
            finalKey[i] = key[i];
        }
        return finalKey;
    } catch (NoSuchAlgorithmException ex) {
        if (LOG.isErrorEnabled()) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_CREATE_KEY_0), ex);
        }
    }
    return null;
}

From source file:org.shareok.data.plosdata.PlosUtil.java

/**
 * /*from   w w  w .jav  a  2 s . c om*/
 * @param html : The string of the web page source
 * @return acknowledge statement
 */
public static String[] getSubjects(String html) {
    List<String> subjectsList = new ArrayList<>();

    Document doc = Jsoup.parse(html.toString());
    Elements subjectListDiv = doc.select("div[class=subject-areas-container]");
    if (null != subjectListDiv && !subjectListDiv.isEmpty()) {
        Element subjectList = subjectListDiv.first().child(1);
        if (null != subjectList) {
            Elements lis = subjectList.select("li");
            if (null != lis && lis.size() > 0) {
                for (Element li : lis) {
                    Element link = li.child(0);
                    subjectsList.add(link.text());
                }
            }
        }
    }
    if (subjectsList.size() > 0) {
        return subjectsList.toArray(new String[subjectsList.size()]);
    } else {
        return null;
    }
}

From source file:Main.java

public static String formatDate(String dateInput) {
    try {//  w ww. ja v a 2 s. c o m
        SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date date = sdfSource.parse(dateInput);
        SimpleDateFormat sdfDestination = new SimpleDateFormat("dd-MM-yyyy");
        dateInput = sdfDestination.format(date);
        return dateInput.toString();

    } catch (ParseException pe) {
        return dateInput;
    }
}

From source file:fi.johannes.kata.ocr.utils.files.CFileOperations.java

public static List<String> getFileContentAsStrings(String f) throws IOException {
    FileReader fr = new FileReader(f.toString());
    BufferedReader br = new BufferedReader(fr);
    List<String> res = getFileContentAsStrings(br);
    fr.close();/*from w w w  .j  a v  a2 s .  com*/
    return res;
}

From source file:com.glaf.core.util.Tools.java

@SuppressWarnings("unchecked")
public static Map<String, Object> getDataMap(Object target) {
    Map<String, Object> dataMap = new TreeMap<String, Object>();
    if (Map.class.isAssignableFrom(target.getClass())) {
        Map<String, Object> map = (Map<String, Object>) target;
        Set<Entry<String, Object>> entrySet = map.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (key != null && value != null) {
                dataMap.put(key.toString(), value);
            }/* w  ww  . j  a  va 2 s .co m*/
        }
    } else {
        PropertyDescriptor[] propertyDescriptor = BeanUtils.getPropertyDescriptors(target.getClass());
        for (int i = 0; i < propertyDescriptor.length; i++) {
            PropertyDescriptor descriptor = propertyDescriptor[i];
            String propertyName = descriptor.getName();
            if (propertyName.equalsIgnoreCase("class")) {
                continue;
            }
            try {
                Object value = PropertyUtils.getProperty(target, propertyName);
                dataMap.put(propertyName, value);
            } catch (Exception ex) {

            }
        }
    }
    return dataMap;
}

From source file:com.nesscomputing.syslog4j.server.SyslogServer.java

/**
 * Throws SyslogRuntimeException unless it has been suppressed via setSuppressRuntimeException(boolean).
 *
 * @param message/*from  w  w  w  . j  ava  2  s .c  o  m*/
 * @throws SyslogRuntimeException
 */
private static void throwRuntimeException(String message) throws SyslogRuntimeException {
    if (SUPPRESS_RUNTIME_EXCEPTIONS) {
        return;

    } else {
        throw new SyslogRuntimeException(message.toString());
    }
}