Here you can find the source of valueOf(Object[] oarray)
Parameter | Description |
---|---|
oarray | The array of objects to be formatted into a single string. |
public static String valueOf(Object[] oarray)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Firestar Software, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from www . j av a 2s . c o m * Firestar Software, Inc. - initial API and implementation * * Author: * Gabriel Oancea * *******************************************************************************/ public class Main { /** * Formats an array of objects into a String suitable for output (logging, etc.). The output format is * "{ v1, v2, ... }", where vN is a value at position N. Null values will be represented by the string "null" and * non-null values will have their "toString()" representation. * * @param oarray The array of objects to be formatted into a single string. * @return The string representation of the objects in the array. */ public static String valueOf(Object[] oarray) { StringBuffer sbuf = new StringBuffer("{ "); for (int i = 0; i < oarray.length; ++i) { String stringValue = oarray[i] == null ? "null" : oarray[i] .toString(); stringValue = trimToLength(stringValue); if (i > 0) sbuf.append(", "); sbuf.append(stringValue); } sbuf.append(" }"); return sbuf.toString(); } private static String trimToLength(String v) { int n = v.indexOf(System.getProperty("line.separator")); if (n > 0) v = v.substring(0, n); if (v.length() > 32) v = v.substring(0, 29) + "..."; return v; } }