Android Open Source - VideoRecorder String Util






From Project

Back to project page VideoRecorder.

License

The source code is released under:

Apache License

If you think the Android project VideoRecorder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2014 The Android Open Source Project
 *//ww w  .j  a v a 2s . co m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Auther?yinglovezhuzhu@gmail.com
 * File: StringUtil.java
 * Date?2014?1?2?
 * Version?v1.0
 */  
package com.opensource.videorecorder.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * ???
 * @author yinglovezhuzhu@gmail.com
 */
public class StringUtil {
  
  private StringUtil() {}
  
  public static boolean isEmpty(String str) {
    return str == null || "".equals(str.trim());
  }
  
  /**
   * ?????startStr?endStr?????????startStr?endStr,?????????startStr?endStr?
   * @param sb
   * @param startStr
   * @param endStr
   */
  public static void deleteAllIn(StringBuilder sb, String startStr, String endStr) {
    int startIndex = 0;
    int endIndex = 0;
    while((startIndex = sb.indexOf(startStr)) >= 0 && (endIndex = sb.indexOf(endStr)) >= 0) {
      sb.delete(startIndex, endIndex + endStr.length());
    }
  }
  
  /**
   * ??????????????????????
   * @param path
   * @return
   */
  public static String getFileName(String path) {
    return path.substring(path.lastIndexOf("/") + 1, path.length());
  }
  
  /**
   * ??????????????????????
   * @param source
   * @param start
   * @param end
   * @return
   */
  public static String getStringIn(String source, String start, String end) {
    return source.substring(source.indexOf(start) + start.length(), source.indexOf(end));
  }
  
  /**
   * Whether the input is valid mobile phone number or not.
   * @param phone
   * @return
   */
  public static boolean isValidPhoneNumber(String phone) {
    if(StringUtil.isEmpty(phone)) {
      return false;
    }
    String p = "1[358][0-9]{9}";
    Pattern pattern = Pattern.compile(p, Pattern.MULTILINE|Pattern.COMMENTS);
    Matcher m = pattern.matcher(phone);
    return m.find();
  }
}




Java Source Code List

com.opensource.videorecorder.BaseActivity.java
com.opensource.videorecorder.Config.java
com.opensource.videorecorder.MainActivity.java
com.opensource.videorecorder.RecorderActivity.java
com.opensource.videorecorder.utils.DateUtil.java
com.opensource.videorecorder.utils.LogUtil.java
com.opensource.videorecorder.utils.StringUtil.java