本文整理了Java中java.util.Arrays.toString()
方法的一些代码示例,展示了Arrays.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.toString()
方法的具体详情如下:
包路径:java.util.Arrays
类名称:Arrays
方法名:toString
[英]Creates a String representation of the byte[] passed. The result is surrounded by brackets ( "[]"), each element is converted to a String via the String#valueOf(int) and separated by ", ". If the array is null, then "null" is returned.
[中]创建传递的字节[]的字符串表示形式。结果用括号(“[]”)包围,每个元素通过字符串#valueOf(int)转换为字符串,并用“,”分隔。如果数组为null,则返回“null”。
代码示例来源:origin: stackoverflow.com
int[] intArray = { 7, 9, 5, 1, 3 };
System.out.println(Arrays.toString(intArray));
代码示例来源:origin: stackoverflow.com
List<String> list = Arrays.asList("foo", "bar", "waa");
CharSequence[] cs = list.toArray(new CharSequence[list.size()]);
System.out.println(Arrays.toString(cs)); // [foo, bar, waa]
代码示例来源:origin: h2oai/h2o-2
private void sampleThresholds(int yi){
_ti[yi] = (_newThresholds[yi].length >> 2);
try{ Arrays.sort(_newThresholds[yi]);} catch(Throwable t){
System.out.println("got AIOOB during sort?! ary = " + Arrays.toString(_newThresholds[yi]));
return;
} // sort throws AIOOB sometimes!
for (int i = 0; i < _newThresholds.length; i += 4)
_newThresholds[yi][i >> 2] = _newThresholds[yi][i];
}
@Override public void processRow(long gid, final double [] nums, final int ncats, final int [] cats, double [] responses /* time...*/){
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
final String str = "<tag>apple</tag><b>hello</b><tag>orange</tag><tag>pear</tag>";
System.out.println(Arrays.toString(getTagValues(str).toArray())); // Prints [apple, orange, pear]
}
private static final Pattern TAG_REGEX = Pattern.compile("<tag>(.+?)</tag>");
private static List<String> getTagValues(final String str) {
final List<String> tagValues = new ArrayList<String>();
final Matcher matcher = TAG_REGEX.matcher(str);
while (matcher.find()) {
tagValues.add(matcher.group(1));
}
return tagValues;
}
代码示例来源:origin: stackoverflow.com
import java.util.*;
//...
List<int[]> rowList = new ArrayList<int[]>();
rowList.add(new int[] { 1, 2, 3 });
rowList.add(new int[] { 4, 5, 6 });
rowList.add(new int[] { 7, 8 });
for (int[] row : rowList) {
System.out.println("Row = " + Arrays.toString(row));
} // prints:
// Row = [1, 2, 3]
// Row = [4, 5, 6]
// Row = [7, 8]
System.out.println(rowList.get(1)[1]); // prints "5"
代码示例来源:origin: netty/netty
/**
* Loads the first available library in the collection with the specified
* {@link ClassLoader}.
*
* @throws IllegalArgumentException
* if none of the given libraries load successfully.
*/
public static void loadFirstAvailable(ClassLoader loader, String... names) {
List<Throwable> suppressed = new ArrayList<Throwable>();
for (String name : names) {
try {
load(name, loader);
return;
} catch (Throwable t) {
suppressed.add(t);
logger.debug("Unable to load the library '{}', trying next name...", name, t);
}
}
IllegalArgumentException iae =
new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names));
ThrowableUtil.addSuppressedAndClear(iae, suppressed);
throw iae;
}
代码示例来源:origin: org.testng/testng
"Arrays not equal: " + Arrays.toString(expected) + " and " + Arrays.toString(actual),
message);
actualCollection.add(a);
if (actualCollection.size() != 0) {
failAssertNoEqual(
"Arrays not equal: " + Arrays.toString(expected) + " and " + Arrays.toString(actual),
message);
代码示例来源:origin: apache/kylin
@Test
public void testGet() throws Exception {
int getNum = 3000;
List<String[]> keys = Lists.newArrayList();
for (int i = 0; i < getNum; i++) {
String[] keyi = new String[] { "keyyyyy" + random.nextInt(sourceRowNum) };
keys.add(keyi);
}
long start = System.currentTimeMillis();
for (int i = 0; i < getNum; i++) {
String[] row = lookupTable.getRow(new Array<>(keys.get(i)));
if (row == null) {
System.out.println("null value for key:" + Arrays.toString(keys.get(i)));
}
}
long take = System.currentTimeMillis() - start;
System.out.println("muliti get " + getNum + " rows, take " + take + " ms");
}
代码示例来源:origin: apache/drill
@Override
public void visitArrayMemberValue(ArrayMemberValue node) {
values.add(Arrays.toString(node.getValue()));
}
});
代码示例来源:origin: apache/drill
out.print(indentString(indent));
if (appendToHeader != null && !appendToHeader.isEmpty()) {
out.println(xpl_note.displayName() + appendToHeader);
} else {
out.println(xpl_note.displayName());
if (outputOperators != null) {
((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put(OUTPUT_OPERATORS,
Arrays.toString(outputOperators.toArray()));
Arrays.sort(methods, new MethodComparator());
out.print(" ");
out.println(val);
List l = val instanceof List ? (List)val : new ArrayList((Set)val);
if (out != null && !skipHeader && l != null && !l.isEmpty()) {
out.print(header);
代码示例来源:origin: apache/hbase
final List<Cell> results = new ArrayList<>();
final List<Cell> actualKVs = new ArrayList<>();
final String columnRestrictionStr =
columnArr.length == 0 ? "all columns"
: ("columns=" + Arrays.toString(columnArr));
final String testDesc =
"Bloom=" + bloomType + ", compr=" + comprAlgo + ", "
long seekCount = StoreFileScanner.getSeekCount() - initialSeekCount;
if (VERBOSE) {
System.err.println("Seek count: " + seekCount + ", KVs returned: "
+ actualKVs.size() + ". " + testDesc +
(lazySeekEnabled ? "\n" : ""));
代码示例来源:origin: org.apache.lucene/lucene-core
String lastSegmentsFile = SegmentInfos.getLastCommitSegmentsFileName(files);
if (lastSegmentsFile == null) {
throw new IndexNotFoundException("no segments* file found in " + dir + ": files: " + Arrays.toString(files));
delCount += info.getDelCount();
infoStream.println(String.format(Locale.ROOT, "%.2f%% total deletions; %d documents; %d deleteions",
100.*delCount/maxDoc,
maxDoc,
result.segmentInfos.add(segInfoStat);
msg(infoStream, " " + (1+i) + " of " + numSegments + ": name=" + info.info.name + " maxDoc=" + info.info.maxDoc());
segInfoStat.name = info.info.name;
代码示例来源:origin: apache/ignite
/**
* Traverse tree on the current level and starts procedure of child traversing.
*
* @param map The current state of the data.
* @param nextPnt Next point.
* @param dimensionNum Dimension number.
*/
private void traverseTree(Map<Integer, Double[]> map, Double[] nextPnt, int dimensionNum) {
dimensionNum++;
if (dimensionNum == sizeOfParamVector){
Double[] paramSet = Arrays.copyOf(nextPnt, sizeOfParamVector);
System.out.println(Arrays.toString(paramSet));
params.add(paramSet);
return;
}
Double[] valuesOfCurrDimension = map.get(dimensionNum);
for (Double specificValue : valuesOfCurrDimension) {
nextPnt[dimensionNum] = specificValue;
traverseTree(map, nextPnt, dimensionNum);
}
}
}
代码示例来源:origin: apache/incubator-gobblin
private String vectorToString(double[] vector) {
List<String> tokens = Lists.newArrayListWithCapacity(this.dimensionIndex.size());
for (Map.Entry<String, Integer> dimension : dimensionIndex.entrySet()) {
tokens.add(dimension.getKey() + ": " + vector[dimension.getValue()]);
}
return Arrays.toString(tokens.toArray());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
static void assertFileContents(final int runNumber) throws IOException {
final Path path = Paths.get(FOLDER + "/audit.tmp");
final List<String> lines = Files.readAllLines(path, Charset.defaultCharset());
int i = 1;
final int size = lines.size();
for (final String string : lines) {
if (string.startsWith(",,")) {
final Path folder = Paths.get(FOLDER);
final File[] files = folder.toFile().listFiles();
Arrays.sort(files);
System.out.println("Run " + runNumber + ": " + Arrays.toString(files));
Assert.fail(
String.format("Run %,d, line %,d of %,d: \"%s\" in %s", runNumber, i++, size, string, lines));
}
}
}
代码示例来源:origin: hankcs/HanLP
break;
default:
System.err.printf("最多支持载入3个模型,然而传入了多于3个: %s", Arrays.toString(models));
return;
if (option.input == null)
scanner = new Scanner(System.in);
scanner = new Scanner(new File(option.input), "utf-8");
System.err.println(e.getMessage());
Args.usage(option);
System.err.println("发生了IO异常,请检查文件路径");
e.printStackTrace();
代码示例来源:origin: androidannotations/androidannotations
private List<AndroidAnnotationsPlugin> loadPlugins() throws FileNotFoundException, VersionNotFoundException {
ServiceLoader<AndroidAnnotationsPlugin> serviceLoader = ServiceLoader.load(AndroidAnnotationsPlugin.class, AndroidAnnotationsPlugin.class.getClassLoader());
List<AndroidAnnotationsPlugin> plugins = new ArrayList<>();
for (AndroidAnnotationsPlugin plugin : serviceLoader) {
plugins.add(plugin);
if (plugin.shouldCheckApiAndProcessorVersions()) {
plugin.loadVersion();
}
}
LOGGER.info("Plugins loaded: {}", Arrays.toString(plugins.toArray()));
return plugins;
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
ArrayList<String[]> listOfStringArrays = new ArrayList<String[]>();
listOfStringArrays.add(new String[] {"x","y","z"});
listOfStringArrays.add(new String[] {"a","b","c"});
listOfStringArrays.add(new String[] {"m","n","o"});
Collections.sort(listOfStringArrays,new Comparator<String[]>() {
public int compare(String[] strings, String[] otherStrings) {
return strings[1].compareTo(otherStrings[1]);
}
});
for (String[] sa : listOfStringArrays) {
System.out.println(Arrays.toString(sa));
}
/* prints out
[a, b, c]
[m, n, o]
[x, y, z]
*/
}
代码示例来源:origin: redisson/redisson
/**
* Loads the first available library in the collection with the specified
* {@link ClassLoader}.
*
* @throws IllegalArgumentException
* if none of the given libraries load successfully.
*/
public static void loadFirstAvailable(ClassLoader loader, String... names) {
List<Throwable> suppressed = new ArrayList<Throwable>();
for (String name : names) {
try {
load(name, loader);
return;
} catch (Throwable t) {
suppressed.add(t);
logger.debug("Unable to load the library '{}', trying next name...", name, t);
}
}
IllegalArgumentException iae =
new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names));
ThrowableUtil.addSuppressedAndClear(iae, suppressed);
throw iae;
}
代码示例来源:origin: apache/incubator-gobblin
throw new IOException(String.format("Path %s does not exist.", path));
log.info(String.format("Found %d input files at %s: %s", inputs.length, path, Arrays.toString(inputs)));
for (FileStatus input : inputs) {
allPaths.add(input.getPath().toString());
allPaths.size() % maxMappers == 0 ? allPaths.size() / maxMappers : allPaths.size() / maxMappers + 1;
while (pathsIt.hasNext()) {
Iterator<String> limitedIterator = Iterators.limit(pathsIt, numTasksPerMapper);
splits.add(new GobblinSplit(Lists.newArrayList(limitedIterator)));
内容来源于网络,如有侵权,请联系作者删除!