Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google appengine not supporting FileOutputStream

I am trying to write to a file in Google appengine but it giving a error message java.io.FileOutputStream is not supported by Google App Engine's Java runtime environment

even though I imported

import java.io.File;
import java.io.FileInputStream;

import java.io.FileOutputStream;
import java.io.IOException;
like image 325
Arun Paul Avatar asked Nov 11 '11 07:11

Arun Paul


2 Answers

Well it's not a java compiler error. This class is a restricted API in Google App Engine you are not allowed to use it.

Read about the GAE Java Runtime Environment and restrictions here: http://code.google.com/appengine/docs/java/runtime.html

The closest you will get to file storage on GAE is the Blobstore API: http://code.google.com/appengine/docs/java/blobstore/

If you need to create files in code GAE is not an appropriate platform for you.

like image 117
Strelok Avatar answered Sep 18 '22 15:09

Strelok


Have you tried using java.io.ByteArrayOutputStream rather than FileOutputStream?

This should allow you to use your external libraries that require files but still work within the GAE JRE white list

like image 45
Stevko Avatar answered Sep 18 '22 15:09

Stevko