Java String Sub String substring(String source, int size)

Here you can find the source of substring(String source, int size)

Description

substring

License

Apache License

Declaration

public static String substring(String source, int size) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String substring(String source, int size) {
        return substring(source, 0, size);
    }//from ww  w .j  a va 2 s  .  c om

    public static String substring(String source, int offset, int size) {
        if (source == null || size < 1 || offset < 0) {
            return "";
        }

        if (source.length() <= (offset + size)) {
            return source;
        }

        return source.substring(offset, size);
    }
}

Related

  1. subString(String s, int startIndex, int count)
  2. substring(String self, Integer startIndex, Integer endIndex)
  3. substring(String source, int beginIndex, int endIndex)
  4. substring(String source, int length, String padding)
  5. substring(String source, int offset, int dataLength)
  6. substring(String source, int startIndex)
  7. subString(String source, int startIndex, int count)
  8. substring(String src, int beginIndex, int endIndex)
  9. substring(String src, int start_idx, int end_idx)