How to save changes back into binary text file

I have a repository with a single binary field that contains an HTML file
I have a pageflow with a form where users can edit content, including the contents of the HTML file.
Can I just treat that like any other property:
If the name of my binary field containing an HTML file is “file”
Can I just treat it like any other field in the repository and do :
<pre>
try{
properties = node.getProperties();
properties[0] = new Property("title",new Value(form.title));
properties[1] = new Property("description",new Value(form.description));
properties[2] = new Property("file",new Value(form.contentText));
properties[3] = new Property("author",new Value(form.author));
node.setProperties(properties);
String title = form.title;
nodeId = node.getId();
title = node.getProperty("title").getValue().toString();
} catch(Exception e){
e.printStackTrace();
error = "error1";
RepositoryManager manager = null;
try{
manager = RepositoryManagerFactory.connect();
NodeOps nodeOps = manager.getNodeOps();
nodeOps.updateProperties(nodeId, properties);
} catch(Exception e){
error += "error2";
e.printStackTrace();
</pre>
Thanks much.

I have a repository with a single binary field that contains an HTML file
I have a pageflow with a form where users can edit content, including the contents of the HTML file.
Can I just treat that like any other property:
If the name of my binary field containing an HTML file is “file”
Can I just treat it like any other field in the repository and do :
<pre>
try{
properties = node.getProperties();
properties[0] = new Property("title",new Value(form.title));
properties[1] = new Property("description",new Value(form.description));
properties[2] = new Property("file",new Value(form.contentText));
properties[3] = new Property("author",new Value(form.author));
node.setProperties(properties);
String title = form.title;
nodeId = node.getId();
title = node.getProperty("title").getValue().toString();
} catch(Exception e){
e.printStackTrace();
error = "error1";
RepositoryManager manager = null;
try{
manager = RepositoryManagerFactory.connect();
NodeOps nodeOps = manager.getNodeOps();
nodeOps.updateProperties(nodeId, properties);
} catch(Exception e){
error += "error2";
e.printStackTrace();
</pre>
Thanks much.

Similar Messages

  • How to save the RichTextBox Content in Text file

    hI ,
    I NEED TO SAVE THE RichTextBox Content in text file ? 

    If this IS a LabVIEW question, here's an example of how to load a rich text file (to help if you don't know how to get a rich text in LabVIEW).
    If you have a Rich Text Box, you can use the invoke method "SaveFile" to match the function you linked to.

  • How to write the resultset into a text file

    how to write the resultset into a text file

    You can use the java.io.* package to write to files.
    API: http://java.sun.com/j2se/1.5.0/docs/api/java/io/package-summary.html
    Tutorial: http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • How to save VISA information into a configuration file

    Hi guys,
    I've got a problem that i can't quite figure out and I'm sure someone else has done this but i have searched the forums and didn't find anything suitable myself.
    I'm trying to save configuration files for my program and then reload them back in so that i can get the same state of the controls.  One of the controls I'd like to save into the configuration file is a VISA control.  has anyone figured out how to save this into configuration files?  I know that OpenG has a write variant to config but Id like to stay away from 3rd party stuff as much as possible.  Does anyone have any suggestions as to how to get around this?
    Thanks
    Brent 
    Solved!
    Go to Solution.

    The alternative to Write Keys, if you don't want a text file, is a BIN file. I do it this way when I don't want users poking around text file trying to change things, and/or for security. And it's fast.
    The attached picture shows, in general, how to do it.
    Richard
    Attachments:
    saveSettings.gif ‏11 KB

  • How to save a UTF-8 encoded text file ?

    hi People
    I have a little script which reads the source text from a layer and saves it to a .txt file. This is on a Mac and all was good until recently when I tried opening the .txt file on a PC in Notepad and found my ˚ degree symbols all whack.
    Resaving the .txt file in TextEdit as Unicode (UTF-8) encoding solved the problem, now opens fine in Notepad.
    But ideally I'd like the script to output the .txt as UTF-8 in the first place. It's currently Western (Mac OS Roman). I've tryed adding in myfile.encoding = "UTF8" but the resulting file is still Western (and the special charaters have wigged out again)
    any help greatly appreciated../daniel
        var theComp = app.project.activeItem;
        var dataRO = theComp.layer("dataRO").sourceText;
        // prompt user to save file
        var theFile = new File ("~/Desktop/"+ theComp.name + "_output.txt");
        theFile = theFile.saveDlg("Save an ASCII export file.");
        if (theFile != null) {          // check user didn't cancel dialog
            theFile.lineFeed = "windows";
            //theFile.encoding = "UTF8";
            theFile.open("w","TEXT","????");
            theFile.writeln("move details:");
            theFile.writeln(dataRO.value.toString());
        theFile.close();

    Hi,
    Got it, it seems, the utf-8 standard use 2-bytes (and more) encoding on accents and special characters.
    I found some info there with some code http://ivoronline.com/Coding/Theory/Tutorials/Encoding%20-%20Text%20-%20UTF%208.php
    However there was some error so I fixed it. (However for 3 and 4 bytes characters i didnt test it. So maybe you'll have to change back the 0xbf to 0x3f or something else.)
    So here is the code.
    Header 1
    function convertCharToUTF(character){
        var utfBytes = "";
        c = character.charCodeAt(0)
        if (c < 0x80) {
            utfBytes =  String.fromCharCode (c);
        else if (c < 0x800) {
            utfBytes =  String.fromCharCode (0xC0 | c>>6);
            utfBytes +=  String.fromCharCode (0x80 | c & 0xbF);
        else if (c < 0x10000) {
            utfBytes = String.fromCharCode (0xE0 | c>>12);
            utfBytes += String.fromCharCode (0x80 | c>>6 & 0xbF);
            utfBytes += String.fromCharCode (0x80 | c & 0xbF);
        else if (c < 0x200000) {
            utfBytes += String.fromCharCode (0xF0 | c>>18);
            utfBytes += String.fromCharCode (0x80 | c>>12 & 0xbF);
            utfBytes += String.fromCharCode (0x80 | c>>6 & 0xbF);
            utfBytes =+ String.fromCharCode (0x80 | c & 0xbF);
            return utfBytes
    function convertStringToUTF(stringToConvert){
        var utfString = ""
        for (var i = 0 ; i < stringToConvert.length; i++){
            utfString = utfString + convertCharToUTF(stringToConvert.charAt (i))
        return utfString;
    var theFile= new File("~/Desktop/_output.txt");
    theFile.open("w", "TEXT");
    theFile.encoding = "BINARY"
    theFile.linefeed = "Unix"
    theFile.write("");//or theFile.write(String.fromCharCode (0xEF) + String.fromCharCode (0xEB) + String.fromCharCode (0xBF)
    theFile.write(convertStringToUTF("Your stuff éàçËôù"));
    theFile.close();

  • Need help on how to add a delimeter into a text file

    Actually, this program reads a textfile. After reading, i need to put certain delimeters after certain characters and print them out to a new file.
    this is how it works :
    for example...
    471117-01-5179052004 VENUE SECURITIES SDN. BHD.
    This is wat the programs read. Now i have to put a semicolon after this numbers ..
    471117-01-5179052004 (;)
    then put another semiclon after this words
    VENUE SECURITIES SDN. BHD.(;)
    But, this text file contains around 2000 lines, and i have to do this for each line...thts y i dunt understand how to code it.

    thanks mr. micheal dunn. Anyway, how can i put this code to read from a text file.....because i need to read the whole text line and put semicolons. i cant use stringbuffer as it only reads a certain length of string..could u tell me how to do this.
    this line is actaully a short line from the text file.
    String str = "471117-01-5179052004 VENUE SECURITIES SDN. BHD.";
    need to put the semicolon is this line actually :
    471117-01-5179052004(;)AVENUE SECURITIES SDN.BHD. (;)000350785A (;)RAHMAN BIN KADIRAN 51, TAMAN MUHIBBAH SUNGAI MATI MUAR 84400(;)JMY(;)SMYSBI (;) 8516 000000030000004600 (;)1581800 ...can u explain wat is tht \\d+-..sorry im a beginner here...hope u can help me out..

  • How to save changes made in a text box?

    I have created a pdf file with text boxes.  The recipients of this file can add their text,but can not save with changes.  What do I have to do to allow the recipients to save their document?

    Thank you, my life just became a whole lot easier

  • How to save an image into an image file?

    I have posted my problem before, nobody replied so I ask again if anybody has any solution??
    I want to save an image, which I created before from a physical file and did some bit-level manipulation, into the same or a new (doesn't matter) physical file (say in png format). But I do not know how to do it. I have tried the FileConnection API and OutputStream and then the method write() to write the byte array, rather this does not solve my problem. I need something like corresponding to J2SE ImageIO.write(image,null) function. Any Idea??
    please.....

    daregazi wrote:
    I have posted my problem before, nobody replied so I ask again if anybody has any solution??
    I want to save an image, which I created before from a physical file and did some bit-level manipulation, into the same or a new (doesn't matter) physical file (say in png format). But I do not know how to do it. I have tried the FileConnection API and OutputStream and then the method write() to write the byte array, rather this does not solve my problem. I need something like corresponding to J2SE ImageIO.write(image,null) function. Any Idea??
    please.....I don't think it's possible in a midlet. You'll have to save the data as a byte[] to a RecordStore and then convert it back again if you want the midlet to redisplay it.

  • How to save html code  into a html file in webdynpro

    Hello Everyone!
    I want create a html page in WebDynpro,
    example :
    String mystr = "<html><head><titile>This is a text</title></head><body> this is body</body></html>";
    I want create a html page and save this to the *.html page , how can i to do ?
    thanks!

    HI! sowmya&Satya
    1st:
    I use method (File>new>file.) create a html under my project . but when I swith web dynpro perspective,  can't found the html file under my current project ?
    2nd:
      public void onActionInputToHtml(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionInputToHtml(ServerEvent)
        String mystr = "<html>.............</html>"
        //@@end
    how to input "mystr" to the html page which I have create in 1st step ?
    3rd :
    how to display the html page In IE when run my project program ?
    Thanks!

  • By error I converted all my files to PDF; how can I change back to my regular files??HELP

    I converted my computer files to PDF how can I reverse the changes??? even my internet explorer. Home version:  HELP The Adobe file I used was a adobe reader 11

    You mention Adobe Reader. Reader cannot convert a file to PDF. Reader lets you view PDF.
    When the Acrobat (Standard or Pro) application is used to create PDF from source files the source files are not deleted.
    Hopefully whatever you used to get a PDF from your source files behaves like Acrobat (does not delete the source file).
    If so, the source files are still present.
    Be well...

  • How to save the text from text area back to a text file?

    Hi all,
    Now I am doing a small panel which containts a JTextArea, this TextArea will read the content from a text file, then display the content of the text file on the TextArea itself.
    My idea is, allow the user to modify the content in the textarea (I set it Editable=true;), then save it. After the user press the save button, the content in the text file will be updated accordng to the user;s modification on TextArea.
    I had done the displaying part by using JavaI/O (BufferReader), now any expert here know how to update the TextArea content back to the text file itself? PLease teach me, THANKS !!!

    NOw I had manage to clear out the error, but now the problem is when I click on the 'save' button, this function clear out the entire text file for me !!!
    The code are as below:
           if(e.getSource()== vButtons[0])
              try{
               String str;
               String Ky = tArea.getText();
               BufferedWriter buffWrite=null;
               BufferedWriter in1 = new BufferedWriter(new FileWriter("Keyword.txt"));
                        buffWrite.write(Ky);
                    buffWrite.flush();
                        buffWrite.close();
                    in1.close();
              catch (IOException ex) {
              ex.printStackTrace();
            if(e.getSource()== vButtons[1])
                  new panel();
                  dispose();
             if(e.getSource()== vButtons[2])
                System.exit(0);           
        }     Please tell me how to save the TextArea to the text file, THANKS !!!

  • I changed my Apple ID, now I can't login to iCloud because it still has my old Apple ID and the password no longer works to log me in. How can I get back into iCloud so that I can switch off Find my iPhone so I can make these changes? Thank you.

    I changed my Apple ID, now I can't login to iCloud because it still has my old Apple ID and the password no longer works to log me in. How can I get back into iCloud so that I can switch off Find my iPhone so I can make these changes? Thank you. (iPhone 4s)

    Well, you're gonna have to recover the password for that Apple ID:
    http://support.apple.com/kb/ht5787

  • I wanna ask you something. My bro has an iPhone 5s that disabled for 23 million because of the time changed to 1976. So, how to make it back into 2015, make it enabled without erase the data

    I  wanna Ask you something. My brother has an iPhone 5s that disabled for about 23 millions minutes  the time changed to 1976. So how to make it back into 2015 without waiting for 23 millions minutes later and enabled it without erasing any data? Please answer me ASAP because I really need it. Thank you for answer!

    Hello theshadowhunters,
    There is not much you can do to change the time back because he will not have access to change the time. The only option to get passed this is to restore the iPhone. Once the iPhone is restored and have a back up, you can put that back on once the restore is complete. For more information, take a look at the article below. 
    Forgot passcode for your iPhone, iPad, or iPod touch, or your device is disabled
    https://support.apple.com/en-us/HT204306
    Regards,
    -Norm G.  

  • How to effect changes made in a jTable into a text file

    i have created a jTable in netbeans6. The table model is DefaultTableModel.
    i'm not understanding the concept of firecellupdate and other events listeners.
    i want the changes i make to the table during runtime to be written into a Text file.
    any help would be greatly appreciated.

    rishi_86 wrote:
    i have created a jTable in netbeans6. The table model is DefaultTableModel.
    i'm not understanding the concept of firecellupdate and other events listeners.
    i want the changes i make to the table during runtime to be written into a Text file.
    any help would be greatly appreciated.you need to add the TableModelListener to your table model.
    for example:
    model.addTableModelListener(new TableModelListener() {
                public void tableChanged(TableModelEvent e) {
                    // TODO Auto-generated method stub               
             });then, you need to put your custom business logic(saving data to a text file, etc) into the tableChanged method.
    From TableModelEvent you can get all information about the model changes.

  • I changed my password on my ipod and when i locked it up I forgot my password how do I get back into my Ipod?

    How can I get back into my ipod that i forgot the password to?

    iOS: Forgot passcode or device disabled - Apple Support

Maybe you are looking for