fusiontables执行ImportRows时的NPE

时间:2012-12-07 07:36:17

标签: java google-fusion-tables

我正在尝试使用Fusiontables.Table.ImportRows将csv文件导入到我的fusion-table中。但是当我运行execute()时,我得到一个没有附加信息的NullPointerException。

我正在使用FusionOAuth2示例代码并实现了另一种方法:

private static void importRows(final String tableId){
 try {

  final String text = "Text,Number,Location\n" +
   "company,13,my street 14";

  final ByteArrayContent byteArrayContent = ByteArrayContent.fromString("text/comma-separated-values", text);
  final Fusiontables.Table.ImportRows importRows = fusiontables.table().importRows(tableId, byteArrayContent);
  importRows.setEncoding("UTF-8");
  importRows.execute();
 } catch (IOException e) {
  e.printStackTrace();
 } catch (NullPointerException e) {
  e.printStackTrace();
 }
}

这是例外:

java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3003)
at java.net.URI.<init>(URI.java:578)
at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:100)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:269)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:408)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449)
at com.google.api.services.samples.fusiontables.cmdline.FusionTablesSample.importRows(FusionTablesSample.java:185)

我错过了什么?

1 个答案:

答案 0 :(得分:0)

您是否更改了初始化fusiontables对象的方式(com.google.api.services.fusiontables.Fusiontables)?