Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Binary File compare - Problem with char 65533

807588Mar 15 2009 — edited Mar 15 2009
Hi,

I tried to copy an sqlite database (a normal text file) out of my *.jar file. The database is in my java project as a resource file. I read every byte and store it directly into the new file, but somewhow it changes 4 Bytes to 65533! The correct values are 2 times 129 and 2 times 144. It's really strange!

Have you an idea why this happens? Or is there a better way how to copy out a resource file?
Thank you for your answers.
        URL u = this.getClass().getResource("/database/resources/mydb.sqlite");
        try {
            InputStreamReader in = new InputStreamReader(u.openStream());

            File outputFile = new File("newdb.sqlite");
            FileWriter out = new FileWriter(outputFile);
            BufferedWriter writer = new BufferedWriter(out);

            while ((c = in.read()) != -1) {
                writer.write(c);
            }
            in.close();
            writer.close();
        } catch(Exception e) {
            jErrorFld.setText(e.toString());
        }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2009
Added on Mar 15 2009
1 comment
353 views