Example usage for java.lang String subSequence

List of usage examples for java.lang String subSequence

Introduction

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

Prototype

public CharSequence subSequence(int beginIndex, int endIndex) 

Source Link

Document

Returns a character sequence that is a subsequence of this sequence.

Usage

From source file:Main.java

public static String firstCharUpper(String input) {
    if (input == null)
        return null;
    String firstChar = input.substring(0, 1).toUpperCase(Locale.getDefault());
    return firstChar + input.subSequence(1, input.length());
}

From source file:Main.java

/**
 * Gets the directory files list.//from w  w  w  .  ja  va 2  s.c om
 * 
 * @param directory
 *            the directory
 * @return the directory files list
 */
public static HashMap<String, File> getDirectoryFilesList(File directory) {

    final HashMap<String, File> directoryList = new HashMap<String, File>();

    if (directory == null) {
        return directoryList;
    }
    if (!directory.exists()) {
        return directoryList;
    }
    if (directory.isDirectory()) {
        final String[] list = directory.list();
        // Some JVMs return null for File.list() when the
        // directory is empty.
        if (list != null) {
            for (final String element : list) {
                final File entry = new File(directory, element);
                if (!entry.isDirectory()) {
                    String name = entry.getName();
                    if (name.length() > 0 && name.contains(".")) {
                        name = (String) name.subSequence(0, name.lastIndexOf('.'));
                        directoryList.put(name, entry);
                    }
                }
            }
        }
    }
    return directoryList;
}

From source file:Main.java

public static String getStarMobile(String phoneNumber) {
    if (TextUtils.isEmpty(phoneNumber) || phoneNumber.length() < 11) {
        return "";
    }// w  w  w.  jav  a 2  s  . c om
    StringBuilder builder = new StringBuilder();
    builder.append(phoneNumber.subSequence(0, 3));
    builder.append("****");
    builder.append(phoneNumber.subSequence(7, 11));
    return builder.toString();
}

From source file:tv.acfun.video.player.resolver.SinaResolver.java

private static String getContentUrl(String vid) {
    double d = Math.random();
    long millis = System.currentTimeMillis() / 64000;
    String key = getKey(vid + "Z6prk18aWxP278cVAH" + String.valueOf(millis) + String.valueOf(d));
    String key2 = key.subSequence(0, 16) + String.valueOf(millis);
    StringBuilder builder = new StringBuilder().append("http://v.iask.com/v_play.php?vid=").append(vid)
            .append("&r=video.sina.com.cn").append("&referrer=http%3A%2F%2Fvideo.sina.com.cn%2F")
            .append("&v=4.1.42.33&p=i&k=").append(key2).append("&ran=").append(d);
    return builder.toString();
}

From source file:org.wso2.stratos.identity.saml2.sso.mgt.ui.Util.java

/**
 * calculate the CustomLoginPage parameter from the request path
 *
 * @param requestPath request path/*w w  w .ja v  a 2  s  .c  o m*/
 * @return loginPage URL
 */
private static String calculateWebContextFromContextPath(String requestPath) {
    requestPath = requestPath.replace("//", "/");
    String subStr = requestPath.subSequence(0, requestPath.lastIndexOf("/")).toString();
    String context = requestPath.subSequence(subStr.lastIndexOf("/") + 1, requestPath.length()).toString();
    return context.trim();
}

From source file:disko.ParagraphDetector.java

public static void detectParagraphs(String s, Collection<Ann> annotations) {
    Matcher m = paragraphSplitter.matcher(s);
    int start = 0;
    while (m.find()) {
        int end = m.start();
        String found = s.subSequence(start, end).toString();
        ParagraphAnn ann = new ParagraphAnn(start, end, found);
        annotations.add(ann);/*  ww  w  .j  a  v a 2s.co m*/
        log.debug("Found ParagraphAnn " + ann);
        start = m.end();
    }
    if (annotations.isEmpty() && s.trim().length() > 0)
        annotations.add(new ParagraphAnn(0, s.length(), s));
}

From source file:poe.trade.assist.GetGithubDownloadStatistics.java

private static void print(String created_at, String owner, String repo, String html_url, String tag_name,
        String browser_download_url, int download_count) {
    System.out.println(String.format("%d\t%s\t%s\t%s\t%s\t%s\t%s", download_count,
            created_at.subSequence(0, "2015-11-07".length()), owner, repo, tag_name, browser_download_url,
            html_url));// w w  w .j av  a 2  s .c  om
}

From source file:org.apache.slider.server.services.security.SecurityUtils.java

public static String hideOpenSslPassword(String command) {
    int start = command.indexOf(PASS_TOKEN) + PASS_TOKEN.length();
    CharSequence cs = command.subSequence(start, command.indexOf(" ", start));
    return command.replace(cs, "****");
}

From source file:com.ms.commons.test.treedb.JsonObjectUtils.java

/**
 * @param inclusiveList0//from w ww  .  j a va2 s. c o m
 * @param jsons0
 * @return
 */
private static String calInclusive(List<Node> inclusiveList, String jsons) {
    StringBuilder sb = new StringBuilder();
    for (Node p : inclusiveList) {
        sb.append(jsons.subSequence(p.kvStart, p.kvEnd + 1));
    }
    return sb.toString();
}

From source file:com.athomas.androidkickstartr.util.ResourcesUtils.java

private static void copyResourcesToFromJar(File target, URL url) throws IOException {
    JarURLConnection connection = (JarURLConnection) url.openConnection();
    JarFile jarFile = connection.getJarFile();

    Enumeration<JarEntry> entries = jarFile.entries();

    while (entries.hasMoreElements()) {
        JarEntry jarEntry = entries.nextElement();
        InputStream is = jarFile.getInputStream(jarEntry);
        String entryPath = jarEntry.getName();

        File file = null;/*  ww w. j a va2s . com*/
        String dirs = "";
        if (entryPath.contains("/")) {
            int lastIndexOf = entryPath.lastIndexOf("/");
            dirs = (String) entryPath.subSequence(0, lastIndexOf + 1);
        }

        File parent = new File(target, dirs);
        parent.mkdirs();

        if (!jarEntry.isDirectory()) {
            String[] splitedPath = entryPath.split("/");
            String fileName = splitedPath[splitedPath.length - 1];
            file = new File(parent, fileName);
            FileUtils.copyInputStreamToFile(is, file);
        }
    }
}