Problems on saving a binary file

Hi,
I have a String object that I need to save on disk, in binary format, for a database implementation project. I am using the FileOutputStream class, like this:
FileOutputStream fos = new FileOutputStream("file.db");
byte[] arrayBytes = new byte[myStr.length()];
arrayBytes = myStr.getBytes();
fos.write(arrayBytes);
fos.close();
The problem is that it saves the string in text (ASCII) format. If I open the file in Notepad it displays all the characters of the string, in a readable format, as it were a .txt file.
I have some friends implementing the project in Delphi, using a class called "FileWriter". Their file is not readable in Notepad. If we try to open it in notepad, only some characters are readable, other are junk characters.
As my professor doesn't want the database file to be readable by an ASCII editor, what can I do to save my String in binary format, like "FileWriter" class in Delphi?
(he said I can't serialize the object to disk)
The strange thing is that the FileOutputStream class documentation says it writes raw bytes of data. If they are raw bytes, how can I read them in notepad?
It's confusing to me... Is there any solution for what I need?
Thanks for your time and help.
Leo Hyppolito.

Like I said - search around. Something simple is:public class XOR {
    public static void main (String[] args) {
        String s = "Hello";
        s = flip (s);
        System.out.println (s);
        s = flip (s);
        System.out.println (s);
    private static String flip (String s) {
        String flippedString = "";
        for (int i = 0; i < s.length (); i ++) {
            flippedString += flip (s.charAt (i));
        return flippedString;
    private static char flip (char c) {
        return (char) (c ^ 0x5678);
}Kind regards,
Levi

Similar Messages

  • Problem with saving a pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21).

    Need advice on a saving file issue. I'm having problem with saving a .pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21). This is new as this error message just recently started to pop-up.

    More information about this issue can be found here:
    https://forums.adobe.com/thread/1672655
    A "quick" fix that worked for me was to uninstall Adobe... then download the base install for Adobe Reader 11.0.
    Then download each of the individual updates and run them sequentially. 
    I've installed back up to the last security update which is version 08 and have been able to do normal Save As operations.
    You will have to disable automatic updates in order to stay at version 08 until Adobe resolves this issue in a later release.
    http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows
    Adobe Reader 11.0 - Multilingual (MUI) installer    AdbeRdr11000_mui_Std
    Adobe Reader 11.0.01 update - Multilingual (MUI) installer    AdbeRdrUpd11001_MUI.msp
    Adobe Reader 11.0.02 update - All languages    AdbeRdrSecUpd11002.msp
    Adobe Reader 11.0.03 update - Multilingual (MUI) installer    AdbeRdrUpd11003_MUI.msp
    Adobe Reader 11.0.04 update - Multilingual (MUI) installer    AdbeRdrUpd11004_MUI.msp
    Adobe Reader 11.0.05 security update - All languages    AdbeRdrSecUpd11005.msp
    Adobe Reader 11.0.06 update - Multilingual (MUI) installer    AdbeRdrUpd11006_MUI.msp
    Adobe Reader 11.0.07 update - Multilingual (MUI) installer    AdbeRdrUpd11007_MUI.msp
    Adobe Reader 11.0.08 security update - All languages    AdbeRdrSecUpd11008.msp

  • Problem in saving modified rtf file in jsp

    hi,
    I have [b]problem in saving modified rtf file in jsp. My scenario is like this:
    I need to open rtf file in jsp and allow user to modify it, after user modifies rtf file in browser, user will press send button. After user pressing send button rtf has to be saved into destination directory(the directory from which its been fetched. I appreciate if any one could send me relevant code for the same.
    thanks
    ram

    1) RTF is not opened in your browser, but in an application that is set to handle the file type (like Word or Wordpad)
    2) from the web you have no control over what that application does
    3) conclusion: what you want is not possible using the web
    Other than that, asking for code without showing that you put some effort into the problem yourself is a sure way of getting flamed. You should know that by now, since you registered more than 2 years ago...

  • Problem with saving an Ai file to PDF in Illustrator CS4 Professional

    Hello guys, I have an interesting problem.  The machine has Windows Vista Enterprise with the latest updates and office 2007 Pro+.  The version of adobe installed is Adobe CS4 Professional, in which has the Illustrator and Acrobat updated to the latest patches.  This has happened to the user over the weekend; all of the sudden when she tries to save an Ai file to PDF, it hangs not even bringing up the dialog box.  However, in all the other Adobe programs are able to save it as a PDF.    Now I am able to print from Illustrator into Acrobat, but it doesn't save it to a full sized "page".  I tried saving any Ai file to a different file and then try to save as a PDF....no dice.   This is the second time around where this has happened.  Now here is the kicker, since I'm an admin it will work like a charm under my login; the user is a restricted user (no admin rights).  I also changed the default printer for her, to a local printer.. (read somewhere about that)  no dice.  Any help would obviously be appreciated.  THX

    Yup, that could also be possible.  Had a similar problem where the IE add-in for Adobe Reader did not work anymore. And I had to get a patch from MS for office.  And it was only available by request only.

  • Problems writing a structured binary file...

    Hi Folks,
    I've been working with one of my students to convert this matlab routine into a VI to no avail:
    fwrite(fout,version,'char');
    fwrite(fout,nchar_text,'short');
    % convert wave_text into array of ascii integers
    fwrite(fout,wave_text,'char');
    % output a null character to terminate string
    %count=fwrite(fout,0,'char');
    fwrite(fout,n_bits,'char');
    fwrite(fout,n_bytes,'char');
    fwrite(fout,data_polarity,'char');
    fwrite(fout,user_data,'float');
    fwrite(fout,s_rate,'ulong');
    fwrite(fout,adrange,'float');
    fwrite(fout,n_pts,'long');
    fwrite(fout,wave,'short');
    fclose(fout);
    I've written a VI that can open the files written by this Matlab procedure with no problem (see openfile.VI), however I can't seem to recreate the method for writing this file to binary (writefile.VI).  I think the Matlab approach is very similar to C, and I'm guessing the issue has to do with converting datatypes effectively.  I've been searching the forms and google, but can't seem to come up with the proper solution.  Any pointers would be greatly appreciated!
    Best,
    Jason Gallant
    Attachments:
    writefile.vi ‏27 KB
    openfile.vi ‏26 KB

    crossrulz wrote:
    The additional bytes for the array and string lengths is what is throwing you off.  Even if you turn it off at the Write Binary File, because you built a cluster they will be in there.  You do not want to cluster up your data in this case.  You need to string together a bunch of Write Binary Files, one for each of your parts of data.  Similar to what you had to do in Matlab.
    Great suggestion!  We tried implementing this, and things are looking better.   I've attatched the new VI that implements this.   There still seems to be a problem, however with the datatypes being written.  As mentioned in the previous post, the data written is:
    version   - 'char
    nchar_text, 'short'
    wave_text, 'char'
    n_bits,'char'
    n_bytes,'char'
    data_polarity,'char'
    user_data,'float'
    s_rate,'ulong'
    adrange,'float'
    n_pts,'long'
    wave,'short'
    Should i be typecasting (or something similar) to string in order to make this readable by my previous routine?
    Attachments:
    writefile.vi ‏38 KB

  • Getting problem while editing a binary file

    Hi All,
    I am trying to edit a binary file using Java.The file contain a string that I have to replace with some other string.For exanple let us assume following is the content of the file -
    õgëÓÌ©™ÿÿ ABC õgëÓÌ©™ÿÿ
    Here, I have to replace this ABC(a string) with some other string.Now,if the replace string length is more than 3(the length of exiting string) then, the binary file is generating some blank space at the end.
    My Code::
    //Here I am trying to insert "Hello" in place of "ABC".
    FileInputStream fis = null;
    fis = new FileInputStream(aFile);
    FileOutputStream to = new FileOutputStream(aF);
    byte[] aTes=new byte[1024];
    String str="Hello";
    aTes=str.getBytes();
    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = fis.read(buffer)) != -1) {
    to.write(buffer, 0, 5);
    to.write(aTes);
    to.write(buffer, 5, bytesRead);
    Plesae guide me to solve this problem.
    Regards,
    Soumitra

    Okay. So was that code you posted supposed to be a failed answer to the question, and you need help with fixing it? Because to me it just looks like code which copies a file, with random modifications. It doesn't look for ABC in any way, it uses the magic number "5" for no apparent reason, and the other modifications are buggy too. So clarification of what the code is supposed to be would be helpful.

  • Problem involving saving over indesign file and pdf

    Kind of a strange one this one....
    I'm currently working on a magazine and have several InDesign files in one folder that i'm working on and a seperate folder where I have saved exported pdf versions of these files. The files are the same names in ach folder eg '1 - 40'  '2 - 39' and so on
    I accidentally saved over one of my InDesign files so I understand I will not be able to recover it as I wasnt using any backup utility.
    However before I saved over the file I had created a pdf version of it and saved it in my pdf folder.  So i'm thinking not all is lost as I can use the pdf file to send to the printers.
    Now here's the strange bit - I am using PC and when I open explorer I can see the folder icon where all my pdf files are saved and can actually see the 'lost/saved over' pdf version as one of the mini thumbnails for that folder - but when I click on the folder to view the files inside it isnt there - instead it shows a thumbnail of the file i saved over it with...!?!
    I'm thinking is there somekind of automatic updating PDF export setting that I may have selected or is it possible that folder icon is using a snapshot of what was inside at a certain point??
    Either way I could really do with recovering this PDF - if anyone has any suggestions i'm more than happy to hear them.
    Thanks
    Mark

    i thought this would help a little
    This is the folder icon - in which all my pdf's are.  The top left thumbnail is the 'missing/saved over' pdf.  So you'd think it would be in there?
    Below is a view of the contents of that folder - (for those of you with good eyesight) you can see that the top left thumbnail from the above picture is nowhere to be seen in this folder!!

  • Read image saved in binary file in Matlab

    Hello,
    I save images in binary file, in one file can be thousands of images, and I would like to read it in Matlab or in some other software.
    So I would like to know if it's posssible and if so I would like to know what exactly I save, when I save image, and how image structure look like.
    Thanks Eva

    Hi Eva,
    I have little knowledge of IMAQ, so I don't know your data type... sorry.
    But in general you read the data in MatLAB. You save the image (only 1) 100 times in the same file. Each image is prepended by a I32 with the total byte count of the image. So that is one pointer for you.
    What you could do is convert your IMAQ image into a LV picture control (this must be possible) and then convert it into a U32 2D-dbl and read this with Matlab.
    Success Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • CS6 Color Channel Problem When Saving Oil Paint Files

    When I save an OIL PAINT file created in Photoshop CS6, it saves with red and blue shapes over the image. Before saving, the image looks fine. I'm running windows 8. Is it me or a CS6 bug?

    There were some driver problems that caused single tile artifacts when running Oil Paint.
    Have you updated your video card driver from the GPU maker's website?

  • Audio sync problem after saving to QuickTime file

    Hi there, I'm relatively new to Adobe Premiere - I'm not quite knowledgeable enough about video editing to really use it to its full potential but needed something more flexible than Windows Movie Maker.  I haven't had any problems before editing smaller files, but am having tons of trouble with a 2.7 gig file.
    I'm trying to take a 2.7GB .MOV file recorded on a Kodak Zi6 and divide it into three roughly equal parts to use an email sharing service that has a maximum file size of 1GB (I know that there are sites that will allow 3GB files and I wish I could use them, or use an FTP server, but the person who needs the video needs it to be sent over his own company's file sharing system).  It was recorded on an 8GB SD card, that SD card was put into my computer, and I then transfered it over to Premiere Elements 8.
    I rendered the entire file first (it wouldn't even play until I did that) and after rendering, the audio and video were good and everything was synced up.  I then split the clip into three and saved each as a separate project.  Then I opened one up again and tried to save as a Quicktime file (that's what the person I'm sending it to requested).  All seemed to go well, and for the first minute or so of the 15 minute clip everything is great.  Then after that, the audio gets more and more out of sync as the video plays on.  I tried playing it on several different players, same thing.
    My computer (a Cyberpower PC) is running an Intel Core i7 CPU, 870 @ 2.93GHz 3.06 GHz; 8 GB of RAM; NVIDIA GeForce GTX 285; Windows 7 Home Premium.  I'm not sure where to get the rest of the information requested in the "How to best ask for help" post but if you can give me some guidance I'll find it.
    The presets are on the defaults because I wasn't aware of them until I came to this forum.  Happy to try the whole process again if someone can tell me what the presets should be changed to.
    I'm looking for a solution to this particular problem, but am also looking for some basic help about files.  The files that I used most often usually come from a Kodak Zi6 (.MOV) or a Flip Mino HD (MPEG4 I think; had to convert those to something else to use them in Premiere at all).  I have AVS Video Converter 6, so I can convert those files to pretty much anything.  I'm wondering what I should convert files to before trying to edit them in Premiere, and how best to save them.  I rarely use the files anywhere but online if that helps (this particular 2.7GB file being a big exception) at a maximum width of 550 pixels, so I don't think I need the quality to be all that great; it's more important to me to be able to work a bit quicker, without rendering that takes hours.
    I'd also love to take advantage someday of some of the more advanced features of Premiere, so I was wondering if anyone knows of any tutorials that will walk me through things in a linear way (as in, start from the beginning and teach me what I need to learn before moving on to something more complicated).
    Thanks so much for your help, and please speak slowly; I'm in over my head!

    Very well-done post, and welcome to the forum.
    First, many have issues with OOS (Out Of Sync) with QT files on Export/Share. This is not just with PrE, but PrPro also. Unfortunately, OOS is pretty easy to fix, when you encounter it on the Timeline, but almost impossible to fix when it creeps in during Export. As an aside, I fought some MPEG Audio from a client, that was perfect in the Timeline, but when Exported to MPEG-2 for DVD-Video, ALWAYS went OOS dynamically, and even adjusting for that on the Timeline (rather guessing how much OOS the other direction I needed,) just flat would not do it. Sync would be fine for awhile, and then suddenly start going out, before miraculously returning to sync with the next Clip. Never could get that one correct.
    In your MOV Export/Share, I am not certain which CODEC you chose. Was it H.264?
    Within the MOV "wrapper," did your recipient give you any options for the enclosed CODEC's, or is the wrapper and the file size the determining factors?
    Wish that I had more to offer directly, rather than questions.
    As for the tutorials, I strongly recommend Steve Grisetti's Learning Series, his Boot Camp and his many articles and general PrE tutorials on Muvipix. He also has several books, available there too.
    Good luck,
    Hunt

  • Problem with saving/loading a file

    hi everyone,
    i hav a program that consists of animal that are jlabels with icons and i put these animals in an array and save them. when i save the file i catch this error message: sun.awt.image.ToolkitImage
    when i try to load the file i catch this error: writing aborted; java.io.NotSerializableException: sun.awt.image.ToolkitImage
    Now i got this :public class Animal extends JLabel implements MouseListener, Serializable{, for my animal class and every other class associated with the animal class also implements Serializable.
    i think its because im using an Image object in another serialised class. what can i do to fix this thing (Does it have anything to do with tooltiptext coz i got that for each jlabel). Any help is appreciated
    regards,
    gher111
    Message was edited by:
    prodigy111

    Most image implementations are not Seriliazable so if you have a field possibly in an outer class which refers to an object etc which contains an image you have a problem.

  • Problem in saving edited pdf files in phone

    it only occur when I save a notation or highlighted text in the PDF file ( around 7.1MB) but when I try to a lower size pdf file, the file is been saved.

    Make sure you disable the Preview pane in Windows Explorer.

  • Problems on Saving a text file

    the "Java Programming" forum is more active compare to "CLDC-MIDP" and "WTK" forum that's why I posted my problem here just case in MIDP programmer dropped by.
    My problem is my phone (Nokia 6260) contains MIDP2.0, the problem is, it has no JSR-75/File Connection API... my application is runs perfectly on my WTK2.2 because it has a JSR-75 jar file...
    but it wont run on my Nokia 6260 phone because of FileConnection API is missing... my question is, is it possible to install the JSR75 on my mobile Nokia6260 phone?
    again, my apology for posting my grievance here...
    thank you so much...

    You can do it by upgrading your firmware .
    If there is upgraded firmware supporting JSR75 then it might solve your problem.

  • Everytime I try to download It says I am saving a Binary File. Then it goes to a blank white page that says downloads at top od page says trying to download and underneath it says canceled.. It shows it is downloading. But can't find it.

    I just seen where it says Windows 32 is not a valid Application. How do I fix that? Will not let me install anything either.

    Hi Barbara,
    I had a similar problem recently and using the "more like this" feature I discovered an answer. To a problem posed by Holo7,  who like myself was a newbie on this platform,  b noir proposed a solution to Holo7's problem that also worked with my problem. It involves downloading a version of MS Windows Instal Cleanup and using it to completely remove all traces of the old version.
    If you look at my problem (follow OldGit66) and the link to Holo7's problem then you will find b noir's answer which I think may help you. I am new around here so you might want to wait for one of the higher status correspondents.
    Regards
    John

  • CS3 problems in saving and opening files and uninstalling software

    ?? In CS3 Photoshop I get error message "Could not complete the SAVE AS command because of a program error?"  or "Could not complete your request because it is  not the right kind of documente?.
    I can save files as bitmap but not as psd, jpg, or tiff.  Is there a link that correlates all error messages?  Also, I am unable to uninstall the CS3 software.  I have my original CS3 software to install, but it will not install over existing file that can not be uninstalled.  Yes, I need help and thanks in advance.

    Read this article regarding installation issues and this one as well. if you are able to reinstall, everything should work out just fine. if not, come back with more pertinent questions and we will try to help
    Mylenium

Maybe you are looking for