Hi,
I am relatiely new to both java and Android.
I assume that files opened in "user.dir" are held in fast battery
backed ram" and that /sdcard/ is a slower rom device.
I am attempting to copy a file of about 450k from the sdcard to the
"user.dir" so that I can have much faster reading/wrting of the file.
CopyfiletoMemory(..) works fine but the subsequent call to open the
file as a
RandomAccessFile in Openfile fails with FileNotFoundException?? any
ideas
public void CopyfiletoMemory(String filename){
try{
FileInputStream in = new FileInputStream("/sdcard/"+filename);
File temp = File.createTempFile("/"+filename, null );
FileOutputStream out = new FileOutputStream(temp);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.flush();
in.close();
out.close();
System.out.println("File Copied");
}
catch (Exception e){
System.err.println("File input error");
}
}
public void Openfile(String filename){
try{
String destination = System.getProperty("user.dir")+
filename;
File fileCon = new File(destination);
fstream = new RandomAccessFile(fileCon.getPath
(),"rw");
ReadRoundData();
customer = new t_customer();
}
catch (FileNotFoundException e){
System.out.println( "File not found exception!:" + e.getMessage
());
}
catch (SecurityException e){
System.out.println( "File security problem!:" + e.getMessage
());
}
catch (Exception e){
System.out.println("File input error");
}
}
Any help gratefully received
Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---