List of usage examples for com.amazonaws.util StringUtils join
public static String join(String joiner, String... parts)
From source file:com.davidsoergel.s3napback.S3ops.java
License:Apache License
public static void list(StreamingTransferManager tx, String bucket) throws InterruptedException { //** sort by date SortedMap<String, SortedMap<String, S3ObjectSummary>> blocks = new TreeMap<String, SortedMap<String, S3ObjectSummary>>(); ObjectListing current = tx.getAmazonS3Client().listObjects(new ListObjectsRequest().withBucketName(bucket)); List<S3ObjectSummary> keyList = current.getObjectSummaries(); ObjectListing next = tx.getAmazonS3Client().listNextBatchOfObjects(current); keyList.addAll(next.getObjectSummaries()); while (next.isTruncated()) { current = tx.getAmazonS3Client().listNextBatchOfObjects(next); keyList.addAll(current.getObjectSummaries()); next = tx.getAmazonS3Client().listNextBatchOfObjects(current); }/*from w w w.j av a 2s.c om*/ keyList.addAll(next.getObjectSummaries()); for (S3ObjectSummary objectSummary : keyList) { String[] c = objectSummary.getKey().split(":"); if (c.length != 2) { logger.warn("ignoring malformed filename " + objectSummary.getKey()); } else { String filename = c[0]; String chunknum = c[1]; SortedMap<String, S3ObjectSummary> chunks = blocks.get(filename); if (chunks == null) { chunks = new TreeMap<String, S3ObjectSummary>(); blocks.put(filename, chunks); } chunks.put(chunknum, objectSummary); } } // now the files and chunks are in the maps in order for (Map.Entry<String, SortedMap<String, S3ObjectSummary>> blockEntry : blocks.entrySet()) { String filename = blockEntry.getKey(); SortedMap<String, S3ObjectSummary> chunks = blockEntry.getValue(); long totalsize = 0; Date lastModified = null; for (Map.Entry<String, S3ObjectSummary> entry : chunks.entrySet()) { totalsize += entry.getValue().getSize(); lastModified = entry.getValue().getLastModified(); } String[] line = { bucket, filename, "" + chunks.keySet().size(), "" + totalsize, lastModified.toString() }; System.err.println(StringUtils.join("\t", line)); // 2008-04-10 04:07:50 - dev.davidsoergel.com.backup1:MySQL/all-0 - 153.38k in 1 data blocks } }