Forums Register Login

How to take back up .mdb file in java

+Pie Number of slices to send: Send
Hi Guy/Gul .......
I have a some problem of take back up of mdb file i have writen one little java pro. for got the copy of mdb file. It work properly up to copy but my original file is password protected that why when i open new copied file it will not opened. Baz that copied file r correpted but it same as original with byte. So it u have a any idea then help me.
Thanks a lots dear friends.
kkjava

import java.io.*;
import java.io.File;

public class BackUpOfCCMS{

public static void main(String args[])throws Exception{
BufferedReader br = new BufferedReader(new FileReader(new File("D://rnd/ccms.mdb")));
String s = null;
FileWriter fo = new FileWriter("c://backup/ccms.mdb");
while((s = br.readLine()) != null){
fo.write(s);
}
fo.close();
br.close();
System.out.println("Done Succesfully");
}
}

take it this and run it's run properly but when u open the new file it is not allow to open it. before take this code pl. make one ccms.mdb (any access file) with password protected. then go ahead
+Pie Number of slices to send: Send
kkjava-
Welcome to the JavaRanch! Please adjust your displayed name to meet the JavaRanch Naming Policy. You can do so here.
Thanks! and again, Welcome to the Ranch!
+Pie Number of slices to send: Send
I don't know if this will solve your problem, but this is an instance when OutputStreams and InputStreams are superior to Readers and Writers. Readers and Writers assume you are working with text, and may actually change a few things. On the other hand, OutputStreams and InputStreams are designed specifically for working with binary data -- like an mdb file.
Try replacing the middle of the file with this:
+Pie Number of slices to send: Send
I ran this code and it said "Access Denied" to the destination folder. How is that posible?
Also when you pass 1024 into this array (right?), what is that doing?
byte[] buffer = new byte[1024];
Is there a way to open the file once it's copied to the destination?
+Pie Number of slices to send: Send
I don't know about the "Access Denied", but the 1024 is just an arbitrary number. When reading from files or the internet or wherever, you generally read in chunks. BufferedReader.readLine() uses chunks the size of a line. InputStream.read() is just one byte.
The InputStream.read(byte[]) and InputStream.read(byte[], int off, int len) methods allow you to read big chunks (in this case the maximum is the arbitrary 1024). Reading and writing bigger chunks all at once is faster than reading and writing several smaller chunks.
Here is a slower alternative:

1024 is just a kilobyte, nothing special. 1234 would have worked just as well (and depending on the file size and computer's free memory, perhaps better).
+Pie Number of slices to send: Send
kainil -
You are still in violation of the Naming Policy. You must have a first name, a space, and a last name. Please change your display name, or you account will be locked out.
Jason
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1459 times.
Similar Threads
Copying MS Access Database
copying file without messing up the content.
Java execute BAT have no response
Java BufferedReader and BufferedWriter
Can't write to file
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:46:41.