Adding a line (String text) to a file ,only if it is not present in the

Please tell me the java code to add a String line to a file.
The condition is the string to be added should not be present in the file
Thanks in advance

Hi ,
The one simple solution is you can read the file in a string.
The check the string you want to insert in the string so formed.
By using
int if((str.indexOf("String to be inserted"))!=-1)
//Insert in the file
else
//dont Insert in the file
Thanks & Regards
Pradeep

Similar Messages

  • I am receiving the data through the rs232 in labview and i have to store the data in to the word file only if there is a change in the data and we have to scan the data continuasly how can i do that.

    i am receiving the data through the rs232 in labview and i have to store the data in to the word or text file only if there is a change in the data. I have to scan the data continuasly. how can i do that. I was able to store the data into the text or word file but could not be able to do it.  I am gettting the data from rs232 interms of 0 or 1.  and i have to print it only if thereis a change in data from 0 to 1. if i use if-loop , each as much time there is 0 or 1 is there that much time the data gets printed. i dont know how to do this program please help me if anybody knows the answer

    I have attatched the vi.  Here in this it receives the data from rs232 as string and converted into binery. and indicated in led also normally if the data 1 comes then the led's will be off.  suppose if 0 comes the corresponding data status is wrtten into the text file.  But here the problem is the same data will be printed many number of times.  so i have to make it like if there is a transition from 1 to o then only print it once.  how to do it.  I am doing this from few weeks please reply if you know the answer immediatly
    thanking you 
    Attachments:
    MOTORTESTJIG.vi ‏729 KB

  • HT4623 My deleted contacts still show up when I want to send a text message. But when I go to my address book there not there only when I want to send a text MSG there name comes up and if I select them it only show there number not name in the message. 

    My deleted contacts still show up when I want to send a text message. But when I go to my address book there not there only when I want to send a text MSG there name comes up and if I select them it only show there number not name in the message.  How an I get rid of that

    Try this...
    have a text convo with the person you want to delete. Go to the top contact in the text convo, hit edit contact, and delete that contact.
    That resolution came from another thread on this issue, and this did solve to poster's issue.

  • My deleted contacts still show up when I want to send a text message. But when I go to my address book there not there only when I want to send a text MSG there name comes up and if I select them it only show there number not name in the message.  How an

    My deleted contacts still show up when I want to send a text message. But when I go to my address book there not there only when I want to send a text MSG there name comes up and if I select them it only show there number not name in the message. How an I get rid of that

    Try this...
    have a text convo with the person you want to delete. Go to the top contact in the text convo, hit edit contact, and delete that contact.
    That resolution came from another thread on this issue, and this did solve to poster's issue.

  • Oracle SQL Developer  error - "The file-based source procedure Name is not present in the database."

    I recently started working on the Oracle SQL developer. I have 'select' privileges on the QA schema and when tried to execute proc in QA. It is giving the error as 'The file-based source <procedure Name>  is not present in the database.  Was it compiled?'
    instead 'you do not have sufficient privileges to execute this procedure'. Did research on internet but with no luck.What configuration changes needed to be done to make it work.Guide me.

    Sounds like you do not have the correct privileges.  What should have been granted to you by the QA user, or some other user with appropriate privileges, is...
    grant EXECUTE on "QA"."<PROCEDURE_OF_INTEREST>" to "<YOUR_USERID>" ;
    Note that a grant of execute on a procedure has nothing to do with grants of select on some or all of QA's tables and views.
    So, as Vadim suggests, from your connection node in SQL Developer's Connections view, if you expand the Other Users node, then expand QA and look in the Procedures node, do you see the procedure of interest?  If not, you cannot expect to be able to execute it from your userid's connection. And even if you do see it, you may have some other privilege that permits viewing but not executing, like...
    The role SELECT_CATALOG_ROLE
    The system privilege SELECT ANY DICTIONARY
    And even if you do not see it there, then having certain other privileges granted to you could permit executing it in general, like...
    The role EXECUTE_CATALOG_ROLE
    The system privilege EXECUTE ANY PROCEDURE
    Also, note that the 3.0 release is a bit dated nowadays. Upgrading to 4.0.3 production or even the 4.1 EA2 (early adopter) release will, in general, give you a better experience.
    Best wishes,
    Gary

  • The Em Key is not configured properly or is corrupted in the file system and doe s not exist in the Management Repository.

    I'm getting this error and is there any way to resolve this without re-creating the service/s again, etc. Just curious if there are any suggestions/steps I may have missed, if not, I'll drop and recreate the services again
    Anyway, I have a backup of the emkey.ora and put it in the sysman/config directory, but still doesn't work... please see below...
    C:\Documents and Settings\abigail>emctl status emkey
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
    Please enter repository password:
    The Em Key is not configured properly or is corrupted in the file system and doe
    s not exist in the Management Repository. To correct the problem:
    1) Copy the emkey.ora file from another OMS or backup machine to the OH/sysman/c
    onfig directory.
    2) Configure the emkey.ora file by running "emctl config emkey -emkeyfile <emkey
    .ora file location>".
    C:\Documents and Settings\abigail>emctl config emkey -emkeyfile E:\app\abigail\p
    roduct\11.2.0\dbhome_1\sysman\config
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
    Please enter repository password:
    The Em Key is already configured. To override the current configuration, run "em
    ctl config  emkey <options> -force".
    C:\Documents and Settings\abigail>emctl config emkey -emkeyfile E:\app\abigail\p
    roduct\11.2.0\dbhome_1\sysman\config -force -sysman_pwd ********
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
    The Em Key could not be configured. Unable to access file E:\app\abigail\product
    \11.2.0\dbhome_1\sysman\config.
    C:\Documents and Settings\abigail>emctl secure dbconsole -sysman_pwd ********
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
    http://ABIGAIL:5501/em/console/aboutApplication
    DBCONSOLE already stopped...   Done.
    Agent is already stopped...   Done.
    Securing dbconsole...   Started.
    Please enter repository schema password:
    Securing dbconsole...   Failed.
    EMKey is misconfigured.

    Sorry but I'll have to ignore your suggestion, and don't worry about how I spend my time
    AND OHMYGODD IT WORKSS!!! For future reference, this is how I solved it based on my searches, actually based on one particular search:
    http://franjv.blogspot.com/2013/08/emkey-problems-in-oracle-rac-11gr2.html
    Thank youuu whoever wrote that and... is it the same "Fran" who helped me the last time?!? Coincidence??
    ANyway, thank youuuu

  • I'm trying to send a jpeg file as an attachment and not embeded in the body of email

    How do I send a jpeg file as an attachment and not embeded in the body of the email.

    In addition to what etresoft says...
    if you prefer not to see the contents of your attachments embedded in your email...
    Open Terminal in Applications>Utilities and paste this in. Then hit return.
    defaults write com.apple.mail DisableInlineAttachmentViewing 1
    To reverse the setting, change the 1 to a 0.

  • Cannot use file for clustered server. Only formatted files on which the cluster resource of the server has a dependency can be used. Either the disk resource containing the file is not present in the cluster group or the cluster resource of the Sql Serve

    Hi
    Windows serv 2012 cluster on sql 2012 cluster with 2 instance. on works fine , Second instanc ewhen i try to creat DB a get this message. 
    Cannot use file  for clustered server. Only formatted files on which the cluster resource of the server has a dependency can be used. Either the disk resource containing the file is not present in the cluster group or the cluster resource of the Sql
    Server does not have a dependency on it.
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5184)
    Any help please
    kam
    KAMEL

    Hi Saurabh
    Exactly I have SQL SERVER 2012
    Failover Clustering   in windows server 2012 with two nodes with
    two instances and exactly I run them in the same server and each instance with
    three drives Backup, Data and log.   
    KAMEL

  • When I click PDF file, the file does not open and  installation software for creative suite automatically begin to start. Even after re-installation of creative suite 5.5, only acrobat reader dose not work and the same phenomena occurs.

    When I click PDF file, the file does not open and  installation software for creative suite automatically begin to start. Even after re-installation of creative suite 5.5, only acrobat reader dose not work and the same phenomena occurs.

    Did you ever install Acrobat? It is not installed automatically with CS, but requires an extra installation step.

  • I bought an LG phone and a $35 dollar plan card. Less than a week later it said I was out of time for texts. Apparently it only gave me minutes, not the plan I wanted. Is there any way I can get the plan without paying again?

    I bought an LG phone and a $35 dollar plan card. Less than a week later it said I was out of time for texts. Apparently it only gave me minutes, not the plan I wanted. Is there any way I can get the plan without paying again?

    So you bought a plan and used it all and want another one for free? I understand you thought it had more texts or whatnot but they won't do that since you already used the other plan.
    That's like going to McDonalds and ordering a double cheeseburger, them giving you a double cheeseburger, you eating it and then realizing you wanted a double quarter pounder and expecting them to give it to you free.

  • Replacing multiple lines of text in a file

    Hello
    I have an interesting problem
    I have a scheduling software which outputs a iCalendar file - this iCalendar file can be read by Kontact but all the events have NO alarm
    I Checked the file and what I need to add is :
    BEGIN:VALARM
    DESCRIPTION:
    ACTION:DISPLAY
    TRIGGER;VALUE=DURATION:-PT15M
    END:VALARM
    before
    END:VEVENT
    problem is that
    1) the scheduling software exports the file often - so any modification would be overwritten - which means I have to have the script run periodically
    2) the script shouldn't run more than once on the file otherwise I would get multiple alarm tags...
    what I though of doing is
    check for
    TZID:America/Toronto
    END:VEVENT
    and replace it with
    TZID:America/Toronto
    BEGIN:VALARM
    DESCRIPTION:
    ACTION:DISPLAY
    TRIGGER;VALUE=DURATION:-PT15M
    END:VALARM
    END:VEVENT
    which should prevent all problems.
    Now the big problem is that I have not found a single way around to have a script doing this for me.
    I have tried sed but it doesn't support multiple lines
    I have tried awk which is able to insert multile lines but somehow cannot search for multiple lines
    The added complication is that I have a lot of special characters in the text to search and replace
    any of you good souls can help me with this???
    Cippa

    This should work:
    #!/bin/bash
    INSERT='BEGIN:VALARM\nDESCRIPTION:\nACTION:DISPLAY\nTRIGGER;VALUE=DURATION:-PT15M\nEND:VALARM'
    sed -e "/TZID:America\/Toronto$/N;s/\(TZID:America\/Toronto\)\n\(END:VEVENT\)/\1\n$INSERT\n\2/" $1
    I just learned from http://www.shell-fu.org/lister.php?id=539

  • Added a check to Text to sequence file result in Test Stand hang up.

    I added the check in text to sequence file translator.vi (the file is attached)
    With this addition I generated the dll.
    Test Stand load the sequence file without any problem for the first time.
    If I add a space to the sequence file and save the file; test stand tries to load the new sequence file saying file has changed do you want to load the new sequence...
    But fails to load the sequence (Test Stand hangs up)
    The only way to overcome is kill the TestStand thru task manager.
    Which displays
    "You chose to end the nonresponsive program, SeqEdit.exe"
    Attached the displayed error (error.doc)
    Attachments:
    Changed code.vi ‏55 KB
    Error1.doc ‏45 KB

    Hi Vidula,
    Is it only when you add a space to the file name that you see this behavior? If, for instance, you add a '1' to the beginging of the file name does the same thing happen?
    Adam
    National Instruments
    Applications Engineer

  • When trying to edit or download a pdf document, it becomes too large or on screen or normal size with many lines of text blacked out. How do I get it to do the normal presentation of the document

    For years my pdf docs downloaded for viewing or editing as normally sized documents.
    Now when I pull up a pdf from file, it becomes too large or becomes normal page size but many of the lines of text are blacked out. How do I correct it to go back to the previous default page size?

    Hi wh4936,
    Are you opening those files in Acrobat or Reader? You can set the default page size in the Page Display preferences. Choose Acrobat/Reader > Preferences in Mac OS, or Edit > Preferences in Windows to access the preference settings. Do the black lines only appear when the PDF is zoomed in? Or are they there regardless of the page magnification?
    Best,
    Sara

  • Code coverage using command line always produces a binary file nearly full of zeros, not workable by Visual

    I'm using Professional Edition 2013. I try to generate a coverage report for a C project, using the command line interface.
    In Visual, configuration of the Linker : Configuration Properties -> Linker -> Advanced -> Profile.
    Then:
    vsinstr.exe my.exe /COVERAGE
    I've got messages from Visual that the instrumentation went well.
    VSPerfCmd.exe /START:COVERAGE /OUTPUT:my.coverage
    my.exe
    VSPerfCmd.exe /SHUTDOWN
    The my.coverage file is created. But it's a binary file, more or less full of zeros. Dropping it into Visual just opens it as a binary file. Full stop.
    I've tried the same commands on very different .exe files and it seems like the my.coverage file has always the same content.
    What am I doing wrong ?
    Thx

    Hi Fred35,
    If you test it with other language project, how about the result? For example, a console app or winform app.
    Reference:
    http://www.codeproject.com/Articles/590346/CodeplusCoverageplusforplusRegressionplusTestsplus
    Based on your description, I think the steps have no issue like this blog here:
    http://blogs.msdn.com/b/cellfish/archive/2008/11/16/native-c-code-coverage-reports-using-visual-studio-2008-team-system.aspx
    So I'm afraid that we would think about others. Maybe it is the dependent dll file issue.
    http://stackoverflow.com/questions/17867591/code-coverage-in-visual-studio-2010-for-native-c-exe-dll
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • File vault: home folder is not located in the usual place...

    All of a sudden I get this error when logging into a filevault protected account.
    *The home folder for "XXXX" is not located in the usual place or cannot be accessed*
    The message goes on to warn me that the folder could have been moved or deleted or is on an unavailable network volume.
    I see that the sparsebundle is right where it should be. I tried searching this board, but I can't find anything threads discussing this error. So, none of the data is accessible. If it was a sparseimage I could just mount it under another user and get the data out, but I have no idea what to do to salvage a sparsebundle. Heck, I didn't even know they existed until 30 min ago.

    I have had no luck in fixing this. I've tried mounting the sparsebundle from the finder, disk utility, and the terminal and get an "Operation not supported on socket" error.
    opening the terminal while logged in to this account brings up a message along the lines of
    no home directory in /Users/AccountName
    Logging in with home = /
    So I thought it may be a permissions problem and reset them to be read write for user group and others, but still can't login or mount the sparsebundle from another account.

Maybe you are looking for

  • The Nokia E51: The things that work, and the thing...

    Wonderful phone. Let me list my accomplishments and outstanding challenges. Challenges * Finding a video player that will play common formats like xVid in LANDSCAPE format. I did find a free app that will download and play anything on Youtube, but ag

  • Quality in playback of quicktime files in FCE

    Hi, I am a new user to FCE and wanted to ask a question.. I am importing quicktime movies from I Stop motion into FCE and have noticed when the movie is in FCE the quality of the movie is dramatically less then what it was when I open the same movie

  • Trouble exporting from FCPX

    I have been trying to export a movie and keep getting this error:  QuickTime Error: -50 Any ideas? I tried uploading to Vimeo and also exporting to the desktop. Both failed.

  • Which SMB router will support broadband at 60 Mbps download?

    Hello, we are trying to decide on which router in the SMB line would support the above speeds on the WAN? The datasheets provide NAT throughput info but I am not sure if that is enough to make a decision. The RV180 series seems to offer NAT throughpu

  • BAPI_EQUI_CHANGE

    hi all,          I have a material XYZ with a serial number of 123. The equipment number is 100. I wanna change this material number to ABC, serial numner to 456. I am using BAPI_EQUI_CHANGE. How do i change these values so as to reflect it in the ta