Example usage for org.apache.commons.lang ArrayUtils toString

List of usage examples for org.apache.commons.lang ArrayUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toString.

Prototype

public static String toString(Object array, String stringIfNull) 

Source Link

Document

Outputs an array as a String handling nulls.

Usage

From source file:com.edgenius.core.model.User.java

public String toString() {
    return new StringBuilder("User name:").append(username).append(". Fullname:").append(fullname)
            .append(". Email:").append(contact != null ? contact.getEmail() : "").append(". Role:")
            .append(ArrayUtils.toString(roles, "NULL")).toString();

}

From source file:com.cloud.utils.S3Utils.java

public static void putDirectory(final ClientOptions clientOptions, final String bucketName,
        final File directory, final FilenameFilter fileNameFilter, final ObjectNamingStrategy namingStrategy) {

    assert clientOptions != null;
    assert isNotBlank(bucketName);
    assert directory != null && directory.isDirectory();
    assert fileNameFilter != null;
    assert namingStrategy != null;

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(//from   ww w.  j  a va  2s  .  c o  m
                format("Putting directory %1$s in S3 bucket %2$s.", directory.getAbsolutePath(), bucketName));
    }

    // Determine the list of files to be sent using the passed filter ...
    final File[] files = directory.listFiles(fileNameFilter);

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(format("Putting files (%1$s) in S3 bucket %2$s.",
                ArrayUtils.toString(files, "no files found"), bucketName));
    }

    // Skip spinning up an S3 connection when no files will be sent ...
    if (isEmpty(files)) {
        return;
    }

    final AmazonS3 client = acquireClient(clientOptions);

    // Send the files to S3 using the passed ObjectNaming strategy to
    // determine the key ...
    for (final File file : files) {
        final String key = namingStrategy.determineKey(file);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(format("Putting file %1$s into bucket %2$s with key %3$s.", file.getAbsolutePath(),
                    bucketName, key));
        }
        client.putObject(bucketName, key, file);
    }

}