I'm attempting to load a file from my hard drive to a file input stream using the code below.
package com.filefinder1;
import java.io.File;
import java.io.FileInputStream;
import android.app.Activity;
import android.os.Bundle;
public class FileFinder_1Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try
{
String pathToFile = "C:\\\\Koala_Small.jpg";
System.out.println("File Path: "+pathToFile);
File file = new File(pathToFile);
FileInputStream fileInputStream = new FileInputStream(file);
}
catch (Exception ex)
{
System.out.println("Error Catch Triggered: "+ex);
}
}
}
I've tried a bunch of different variations on the file path but nothing everything returns the following error:
01-10 10:59:06.189: I/System.out(2218): Error Catch Triggered: java.io.FileNotFoundException: /C:\\Koala_Small.jpg (No such file or directory)
Some where along the way an extra "/" seems to be getting added to the file path (not sure why). When I ask the system to print the file path prior to trying to load it into a file variable it returns:
01-10 10:59:06.189: I/System.out(2218): File Path: C:\\Koala_Small.jpg
I have tried a bunch of different variations of the file path (lowercase "c", two slashes instead of four...) nothing seems to fix the problem. Does any one have any idea what might be going wrong here?