how to structure the array in java

2019-09-02 14:40发布

问题:

I am a newbie to java, so please forgive my ignorance. I am getting list of objects from amazon s3. I am now struggling to put it in an array that i can use.

I am getting the array but its not exactly how i want. The objectlist that i get looks like the following.

 ObjectListing listKey = s3client.listObjects(new ListObjectsRequest().withBucketName(bucket).withPrefix(key).withDelimiter("/"));
        List<String> keys = new ArrayList<String>();
        for(String obj2: listKey.getCommonPrefixes()){
            String test=obj2;
            keys.add(test);
        }
        for (S3ObjectSummary obj : listKey.getObjectSummaries()) {
            keys.add(obj.getKey());
        }
        return keys;

And the array i get through this code looks like this

this array is fine, but i also want to add the size and lastmodified of the objectsummary. But i should able to know that what size and lastmodified belongs to what key. I don't just want the index but properties of one index or one object summary. some thing like the following,

I just edited the picture, it doesn't have to make perfect sense i am just trying to point out the structure i want. Any help would be greatly appreciated, Thank you.