Example usage for java.lang String format

List of usage examples for java.lang String format

Introduction

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

Prototype

public static String format(String format, Object... args) 

Source Link

Document

Returns a formatted string using the specified format string and arguments.

Usage

From source file:Main.java

public static String formatByteToMB(int size) {
    float mb = size / 1024f / 1024f;
    return String.format("%.2f", mb);
}

From source file:ch.systemsx.cisd.openbis.generic.shared.util.WebClientFilesUpdater.java

public static void main(final String[] args) {
    final int len = args.length;
    final String workingDirectory;
    final String[] technologies;
    switch (len) {
    case 0://  w w w  .  j  a v  a 2s. c  o  m
        workingDirectory = null;
        technologies = null;
        break;
    default:
        workingDirectory = args[0];
        technologies = new String[len - 1];
        for (int i = 1; i < len; i++) {
            technologies[i - 0] = args[i];
        }
        break;
    }
    final WebClientFilesUpdater webClientFilesUpdater = new WebClientFilesUpdater(workingDirectory,
            technologies);
    webClientFilesUpdater.updateOpenBISGwtXmlFile();
    System.out.println(String.format("'%s' has been updated.", OPENBIS_GWT_XML_FILE_NAME));
    webClientFilesUpdater.updateClientPluginProvider();
    System.out.println(String.format("'%s' has been updated.", CLIENT_PLUGIN_PROVIDER_CLASS));
}

From source file:Main.java

public final static String format(String format, Object... args) {
    try {// ww w  . ja  v a2  s.  co m
        return String.format(format, args);
    } catch (Exception e) {
    }

    return format;
}

From source file:Main.java

public static String getSharedLibsPath(Context context) {
    return String.format("%s/lib/", context.getApplicationInfo().dataDir);
}

From source file:Main.java

public static String getBankLogoPath(String logoName) {
    return String.format("bank/%s.png", logoName);
}

From source file:Main.java

public static String getStringFromTime(int time) {
    return String.format("%04d", time);
}

From source file:Main.java

public static String printPrettyDateCalendar(Calendar calendar) {
    return String.format("%1$ta %1$td %1$tb %1$tY", calendar);
}

From source file:Main.java

public static String subscriberOnNext(String variableName) {
    return String.format("subscriber.onNext(%s)", variableName);
}

From source file:Main.java

public static String subscriberOnSuccess(String variableName) {
    return String.format("subscriber.onSuccess(%s)", variableName);
}

From source file:Main.java

public static String getFormattedValue(float f, String s) {
    return Html.fromHtml(String.format("%s %.2f", new Object[] { s, Float.valueOf(f) })).toString();
}