我想获取一个文件夹中所有文件的数量。
public List getList(String id, Integer page, Integer limit) throws GeneralSecurityException, IOException {
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
Drive service = new Drive.Builder(HTTP_TRANSPORT, driveQuickstart.JSON_FACTORY, driveQuickstart.getCredentials(HTTP_TRANSPORT))
.setApplicationName(driveQuickstart.APPLICATION_NAME)
.build();
String q = "trashed = false and '" + id + "' in parents ";
FileList result = service.files().list()
.setQ(q)
.setFields("*")
.setOrderBy("mimeType")
.setPageSize(limit)
.execute();
List<File> files = result.getFiles();
if (files == null || files.isEmpty()) {
System.out.println("No files found.");
} else {
System.out.println("Files:");
for (File file : files) {
System.out.printf("%s %s (%s) (%s)\n", file.getName(), file.getFullFileExtension(), file.getId(), file.getWebViewLink());
}
System.out.println(result.getFiles());
}
return files;
}
如果setPageSize,如何返回文件数