6

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;
Adam Rackis
  • 82,527
  • 56
  • 270
  • 393
Arun Paul
  • 81
  • 1
  • 3

3 Answers3

10

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.

Strelok
  • 50,229
  • 9
  • 102
  • 115
  • thank you Strelok, is it possible to upload file to another ftp server with gwt or gxt components in front end?? – Arun Paul Nov 12 '11 at 05:09
  • 1
    No, you can't open any socket connection except by using URL Fetch service on HTTP/HTTPS to these port ranges: 80-90, 440-450, 1024-65535. – Strelok Nov 12 '11 at 06:34
  • I am not sure what your requirements are but here is how you write to the blob store http://code.google.com/appengine/docs/java/blobstore/overview.html#Writing_Files_to_the_Blobstore – Strelok Nov 12 '11 at 06:38
  • thanks again, sir i wish to upload file to another server using ftp not to GAE – Arun Paul Nov 12 '11 at 06:46
3

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

Stevko
  • 4,345
  • 6
  • 39
  • 66
0

GAE platform allows only read access to Filesystem within scope pf application files. If at all you have to write something, Datastore and Blobstore is the place to write to!

Vishal Biyani
  • 4,297
  • 28
  • 55