Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:16:36+00:00 2026-05-28T08:16:36+00:00

I am attempting to write a file to external storage in android. I keep

  • 0

I am attempting to write a file to external storage in android. I keep getting the error, “java.io.FileNotFoundException: /mnt/sdcard/Survey.txt (Is a directory).” The method that contains the code for this is as follows:

public String sendFile(System system) throws FileNotFoundException {

    File writeable = new File(Environment.getExternalStorageDirectory()
            .getAbsolutePath() + "/Survey.txt");
    try {
        writeable.createNewFile();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    try {

        Log.w("Before FO", "***");
        if (!Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED)) {
            Toast.makeText(context, "External SD card not mounted",
                    Toast.LENGTH_LONG).show();
        } else {
            FileOutputStream f = new FileOutputStream(writeable);
            Log.w("before write", "0");

            f.write("HELLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO".getBytes());
            Log.w("before write", "1");
            f.close();
        }
    } catch (Exception e) {
        Log.w("Write sd", e.toString());
    }

    return writeable.getAbsolutePath();
}

I believe the program is crashing on the FileOutputStream deceleration, because Log.w(“Before FO”, “*“); executes. I have been searching for an answer to this problem for several day, so any help will be greatly appreciated. Thanks!

01-19 14:07:33.839: W/Before FO(641): ***
01-19 14:07:33.857: W/Write sd(641): java.io.FileNotFoundException: /mnt/sdcard/Survey.txt (Is a directory)
01-19 14:07:33.857: W/Write sd(641):    at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
01-19 14:07:33.857: W/Write sd(641):    at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:239)
01-19 14:07:33.857: W/Write sd(641):    at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
01-19 14:07:33.857: W/Write sd(641):    at java.io.FileOutputStream.<init>(FileOutputStream.java:77)
01-19 14:07:33.857: W/Write sd(641):    at premise.survey.IOInterface.sendFile(IOInterface.java:315)
01-19 14:07:33.857: W/Write sd(641):    at premise.survey.PremiseSurveyActivity.onClick(PremiseSurveyActivity.java:1119)
01-19 14:07:33.857: W/Write sd(641):    at android.view.View.performClick(View.java:3110)
01-19 14:07:33.857: W/Write sd(641):    at android.view.View$PerformClick.run(View.java:11934)
01-19 14:07:33.857: W/Write sd(641):    at android.os.Handler.handleCallback(Handler.java:587)
01-19 14:07:33.857: W/Write sd(641):    at android.os.Handler.dispatchMessage(Handler.java:92)
01-19 14:07:33.857: W/Write sd(641):    at android.os.Looper.loop(Looper.java:132)
01-19 14:07:33.857: W/Write sd(641):    at android.app.ActivityThread.main(ActivityThread.java:4123)
01-19 14:07:33.857: W/Write sd(641):    at java.lang.reflect.Method.invokeNative(Native Method)
01-19 14:07:33.857: W/Write sd(641):    at java.lang.reflect.Method.invoke(Method.java:491)
01-19 14:07:33.857: W/Write sd(641):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-19 14:07:33.857: W/Write sd(641):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-19 14:07:33.857: W/Write sd(641):    at dalvik.system.NativeStart.main(Native Method)
01-19 14:07:33.857: I/ActivityManager(73): Starting: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) } from pid 641
01-19 14:07:33.857: W/WindowManager(73): Failure taking screenshot for (230x341) to layer 21020
01-19 14:07:34.027: I/ActivityManager(73): Starting: Intent { act=android.intent.action.SEND typ=plain/text flg=0x3000000 cmp=com.android.email/.activity.MessageCompose (has extras) } from pid 641
01-19 14:07:35.269: I/ActivityManager(73): Displayed com.android.email/.activity.MessageCompose: +1s197ms (total +1s391ms)
01-19 14:07:40.647: D/dalvikvm(252): GC_EXPLICIT freed 164K, 5% free 7462K/7815K, paused 4ms+3ms
01-19 14:07:45.727: D/dalvikvm(269): GC_EXPLICIT freed 8K, 8% free 6305K/6791K, paused 13ms+5ms
01-19 14:12:04.720: D/SntpClient(73): request time failed: java.net.SocketException: Address family not supported by protocol
01-19 14:12:15.947: I/Email(293): ReconcilePopImapAccountsSync: start
01-19 14:12:15.977: I/Email(293): ReconcilePopImapAccountsSync: done
01-19 14:12:16.137: D/dalvikvm(293): GC_CONCURRENT freed 236K, 8% free 7787K/8391K, paused 4ms+7ms
01-19 14:12:16.137: W/CursorWrapperInner(293): Cursor finalized without prior close()


Line 315 in IOInterface.java is FileOutputStream f = new FileOutputStream(writeable);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:16:36+00:00Added an answer on May 28, 2026 at 8:16 am

    After doing a few more hours of research on this topic, I found a place were another person had posted a different way of doing this, and it is as follows:

    String fileName = surveyName + ".csv";
    String headings = "Hello, world!";
    File path = Environment.getExternalStorageDirectory();
    File file = new File(path, fileName);
    path.mkdirs();
    OutputStream os = new FileOutputStream(file);
    os.write(headings.getBytes());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to write a file using java.io, where I am trying to
I'm attempting to write an ASCII null character (nul) to a file from a
I am attempting to open the current process's executable file for read-write operations (I
I'm attempting to write a bash script to parse out the following log file
I am attempting to write some Java code that takes an image from a
I am attempting to write a simple game server for an Android game using
I'm attempting to write a program that will generate a text file with every
I am attempting to write some code to read in a *.CSPROJ file using
I'm attempting to download an external mp3 into internal storage. However, the files I'm
I am attempting to write an sql command into an sql file so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.