如何得到孩子';使用java的google Drive中的文件夹名

如何得到孩子';使用java的google Drive中的文件夹名,java,google-api,google-drive-api,google-api-java-client,Java,Google Api,Google Drive Api,Google Api Java Client,我正在使用java中的GoogleDriveAPI。我的代码中有儿童文件夹Id,但我想要儿童文件夹名称。我应用了all方法来获取孩子们的文件夹名,但并没有获取 Drive.Children.List FolderID = service.children().list(child.getId()); 从这段代码中,我得到了类似0B3-sXIe4DGz1c3RhcnRlcl9的文件夹Id Drive.Children.List Foldername = service.children().l

我正在使用java中的GoogleDriveAPI。我的代码中有儿童文件夹Id,但我想要儿童文件夹名称。我应用了all方法来获取孩子们的文件夹名,但并没有获取

Drive.Children.List FolderID = service.children().list(child.getId());
从这段代码中,我得到了类似0B3-sXIe4DGz1c3RhcnRlcl9的文件夹Id

 Drive.Children.List Foldername = service.children().list(child.getId().getClass().getName());
在这段代码中,它返回{folderId=java.lang.String}


如何获取文件夹的名称?

在Google drive中,文件夹是文件。您具有用于返回包含文件夹标题的文件夹id

从文档中撕下的代码


除了类名之外,您希望
getClass().getName()
返回什么?Title是子文件夹的名称。printFile(服务,“0B3-SXIE4DGZ1C3RHCNRLC9”)我找不到此方法。请解释一下这个方法看看我的答案方法就在那里。实际上,你应该试着阅读文档和关于这个问题的完整答案。
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpResponse;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.File;

import java.io.IOException;
import java.io.InputStream;

// ...

public class MyClass {

  // ...

  /**
   * Print a file's metadata.
   *
   * @param service Drive API service instance.
   * @param fileId ID of the file to print metadata for.
   */
  private static void printFile(Drive service, String fileId) {

    try {
      File file = service.files().get(fileId).execute();

      System.out.println("Title: " + file.getTitle());
      System.out.println("Description: " + file.getDescription());
      System.out.println("MIME type: " + file.getMimeType());
    } catch (IOException e) {
      System.out.println("An error occured: " + e);
    }
  }

  /**
   * Download a file's content.
   *
   * @param service Drive API service instance.
   * @param file Drive File instance.
   * @return InputStream containing the file's content if successful,
   *         {@code null} otherwise.
   */
  private static InputStream downloadFile(Drive service, File file) {
    if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
      try {
        HttpResponse resp =
            service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl()))
                .execute();
        return resp.getContent();
      } catch (IOException e) {
        // An error occurred.
        e.printStackTrace();
        return null;
      }
    } else {
      // The file doesn't have any content stored on Drive.
      return null;
    }
  }

  // ...
}