1

I'm trying to download from ftp server in my android app but when i create the local file i can't write in.

Here the code:

        String servidor = ips[0];
        int reply;
        ftp.setDataTimeout(1000);
        ftp.connect(servidor);
        ftp.login(usuaris[0], pass[0]); // ftp.login( username password)
        //ftp.changeWorkingDirectory(".");
        ftp.setFileType(FTP.ASCII_FILE_TYPE);
        File file = new File("resultat.txt");
        FileOutputStream fos = new FileOutputStream(file); 
        ftp.retrieveFile("ARTI.txt", fos);
        fos.close();

And when i do this

FileOutputStream fos = new FileOutputStream(file);

i have this exception:

java.io.FileNotFoundException: resultat.txt: open failed: EROFS (Read-only file system)

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
Xavi
  • 67
  • 7
  • possible duplicate of [Trying to create a file in Android: open failed: EROFS (Read-only file system)](http://stackoverflow.com/questions/15711098/trying-to-create-a-file-in-android-open-failed-erofs-read-only-file-system) – initramfs Jul 21 '15 at 16:25
  • Add the `android.permission.WRITE_EXTERNAL_STORAGE` permission to your manifest. – initramfs Jul 21 '15 at 16:26
  • i have the premission too. – Xavi Jul 21 '15 at 16:35

1 Answers1

1

It sounds like you don't have the right directory or file location at the server level.

Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106
  • Thank's i'solved my problem! The problem was that i create the new file in a unknow location. Now i put this and it works: File file = new File("/sdcard/resultat.txt"); – Xavi Jul 21 '15 at 17:03