Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google appengine可以存储java对象POJO_Java_Google App Engine - Fatal编程技术网

Google appengine可以存储java对象POJO

Google appengine可以存储java对象POJO,java,google-app-engine,Java,Google App Engine,应用程序引擎是否可以存储ObjectOutputStream之类的信息?GAE确实支持Blob数据。但也有一些尺寸限制。这是你的电话号码 但另一个选择是使POJO从com.google.appengine.api.datastore.Entity扩展为可序列化的,GAE可以存储信息。如果您正在查找相关文档或信息,请选中此项。可以查找有关扩展实体的更多信息。当然,GAE可以存储大量数据。用于高达1Mb的数据,用于较大的对象 FileService fileService = FileS

应用程序引擎是否可以存储ObjectOutputStream之类的信息?

GAE确实支持Blob数据。但也有一些尺寸限制。这是你的电话号码


但另一个选择是使POJO从com.google.appengine.api.datastore.Entity扩展为可序列化的,GAE可以存储信息。如果您正在查找相关文档或信息,请选中此项。可以查找有关扩展实体的更多信息。

当然,GAE可以存储大量数据。用于高达1Mb的数据,用于较大的对象

      FileService fileService = FileServiceFactory.getFileService();

      // Create a new Blob file with mime-type "text/plain"
      AppEngineFile file = fileService.createNewBlobFile("text/plain");

      // Open a channel to write to it
      boolean lock = true;
      FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);




      MyObject obj = new MyObject();
      obj.name="testing now";
      ObjectOutputStream oos = new ObjectOutputStream(Channels.newOutputStream(writeChannel));
      oos.writeObject(obj);
      oos.flush();
      oos.close();
      // Now finalize
      writeChannel.closeFinally();

      // Later, read from the file using the file API
      FileReadChannel readChannel = fileService.openReadChannel(file, false);
      ObjectInputStream ooi = new ObjectInputStream(Channels.newInputStream(readChannel));
      resp.setContentType("text/plain");
      try {
        resp.getWriter().print(ooi.readObject().toString());
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
下面是将POJO保存到blobstore的代码。MyObject需要实现可序列化接口