Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.google.sitebricks.rendering;

A string-specific set of utilities.

Author(s):
Dhanji R. Prasanna (dhanji@gmail.com)
 
 public class Strings {
   private Strings() {
  }

  
Tests for null or emptiness of a string, throwing an java.lang.IllegalArgumentException if one is encountered.

Parameters:
aString Any string to test for emptiness.
message A message to throw inside an IllegalArgumentException if the aString was empty.
  public static void nonEmpty(String aStringString message) {
    if (empty(aString))
      throw new IllegalArgumentException(message);
  }

  

Parameters:
string Any string to test for emptiness.
Returns:
True if this string is empty or null.
  public static boolean empty(String string) {
    return null == string || "".equals(string.trim());
  }
  public static String join(String[] stringschar sep) {
    StringBuilder builder = new StringBuilder();
    for (String string : strings) {
      builder.append(string);
      builder.append(sep);
    }
    builder.deleteCharAt(builder.length() - 1);
    return builder.toString();
  }
New to GrepCode? Check out our FAQ X