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 8532905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:49:27+00:00 2026-06-11T09:49:27+00:00

In the below program i get the exception as shown below.Basically what i am

  • 0

In the below program i get the exception as shown below.Basically what i am trying to do is i am copying a file from a remote system to the device.but when saving to the memory card both on the emulator and device i am hitting an exception.The below exception is from the emulator where i can say that the memory card is not attached to the emulator and so the exception.but will the code work for a physical device.

How to make the code work on emulator and the device

Exception:

 09-13 15:47:16.789: I/System.out(400): java.io.FileNotFoundException: /mnt/sdcard/Download/new.txt (Not a directory)

Code:

package com.scp2;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import com.jcraft.jsch.*;


import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.Toast;

public class Scp2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

            JSch jsch = new JSch();
            Session session = null;
            try {
                session = jsch.getSession("guest", "17.30.5.2", 22);

                session.connect();
                Toast.makeText(this,  "in try2" , Toast.LENGTH_SHORT).show();

                channel.connect();
                ChannelSftp sftpChannel = (ChannelSftp) channel;
                File ofile = new File(Environment.getExternalStoragePublicDirectory (Environment.DIRECTORY_DOWNLOADS),"new.txt");
                Toast.makeText(this, ofile.toString() , Toast.LENGTH_SHORT).show();
                                   try {
                    FileOutputStream f = new FileOutputStream(ofile);
                  sftpChannel.get("/root/a.txt","/mnt/sdcard/download/dd.txt");
                  /*OR What shoud the abobe statement be **/
              //sftpChannel.get("/root/a.txt",ofile); or this statement is correct

                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                         System.out.println(e.toString());
                }


                sftpChannel.exit();
                session.disconnect();
            } catch (JSchException e) {
                e.printStackTrace(); 

            } catch (SftpException e) {
                e.printStackTrace();

            }


    }
 }
  • 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-06-11T09:49:28+00:00Added an answer on June 11, 2026 at 9:49 am

    Do this for file creation ; a better and safer way than yours

    File dir = new File(Environment.getExternalStorageDirectory(),"/Downloads/");
    dir.mkdirs();
    String strFileName = "dd.html";
    File file = new File(dir,strFileName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the below code i need to get a parse exception.but the program somehow
Below is my program and I am trying to get the call stack when
The two programs below get n integers from file and calculates the sum of
Am trying to get some order information from XML file and trying to store
I use SimpleDataFormat for years. I never get this Exception the program is below,
I am using the code shown below to get Data from our server where
This is my code below. The program runs fine. I don't get any exceptions.
Below program contains two show() functions in parent and child classes, but first show()
In the below program,i am not getting values from printf . #include<stdio.h> int main()
I have the below program that will move files from one directory to other.

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.