Question: I have an Android Java application and I am trying to create a file and write something into it:

```
    try {
        File file = new File( "/storage/emulated/0/text.txt" );
        file.createNewFile();
        FileWriter fwr = new FileWriter( file );
        fwr.write( "something" );
        fwr.close();
    } catch( Exception e ) {
        e.printStackTrace();
    }

```

When I run the app, this line: 
 `file.createNewFile();`
gives me the following error: 
 `open failed: ENOENT (no such file or directory)`
probably because I don't have the rights to write there. What am I doing wrong? Where do I have the rights to create a file? I don't want the file to be part of the app, such as a properties file. I want my file to be independent, and inside the home directory of the user.

Edit: When I try to open the file in the Movies directory like this: `File file = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_MOVIES ) + "/movielist.txt" );` I get this error: `open failed: EACCESS: Permission denied`

Answer: 
`playerInput` is too short. You need room for your input, plus a newline, plus nul. Your first `fgets()` stops before the end of the line because it's out of buffer space (though you overrun the buffer anyway, because you specify a size larger than the actual array)... then the second `fgets()` reads the rest of the line (which has the newline).
If the result from fgets does not end with a newline you have not read all the data.
you now need to decide what to do with the unread data. one option would be to call getchar until you see a newline (or EOF)

```
// discard he rest of the line:

if(! strchr( playerinput,'\n')
{
  int c;
  do 
  {
    c=getchar(stdin);
  }
  while ( c != EOF && c != '\n');
}

```