How to replace single backslash(\) to double backslash(\\)

Hi
I want to replace single backslash to double backslash from the string.
Code is here
String data="File name :\n.txt;File name:\t.txt";               
data = data.replace("\\","\\\\");
System.out.println("-->" +data);
i tried to this code but its not working. Help me if anyone is know.
Please reply me asap.
Thanks

DVekaria wrote:
Are you not getting my question.Obviously not. That's why we've asked you to clarify it. Twice, at least.
whatever data contenting in Variable, it must print as its on the screen.This code does that.
String s = "a\nb\tc;"
System.out.println(s);The variable s contains a reference to a String object. That String object holds 5 characters: 'a', newline, 'b', tab, 'c'. The println prints out exactly what's in that String--those 5 characters. Note that there is not even one single backslash in that String.
a
b cThis is exactly what you asked for.
Now let's say I create a file in Notepad, and I type the following, and then save it:
a\nb\tcThat file contains 7 characters. 'a', '\', 'n', 'b', '\', 't', 'c'. If I read that file with Buffered reader, it will give me a String object with those same 7 charcters. If I print it out it will print out those 7 characters.
a\nb\tcNote that in both cases, I am printing out exactly what is in the String.
Think carefully on what is the same and what is different between those two cases, and use it to form a clearer definition of your problem. Remember, we want to know what you're trying to accomplish. Just saying "I want to replace backslashes" tells us how you're trying to solve your problem.

Similar Messages

  • How to replace single quote with double quote

    hai all,
    i have a problem,
    i am trying insert a string containing single quote into ms-access database.
    it is giving error.
    how can i avoid this .if i replace a single quote in the text with double quote it will defenitely
    insert into database.
    in java.lang.String
    replace () will not work to replace quote with double quote.
    any otherway to solve this problem.
    please mail me to [email protected]
    thank you
    sambareddy
    inida

    java.lang.String.replace () will not work to replace quote with double quote.Really?
    String x = ...
    x.replace( "'", "\"" );

  • Replace Single Quote with double quote

    Hi All,
    I have a String s="help'me'to'replace";
    i want to replace single quote( ' ) in to double quote ( " )
    The final out put should be like this help"me"to"replace
    ( Actually this string i have to pass in to an XML )
    Please help any one

    s.replaceAll("'","\"");{code}
    or just one of the String#replace() methods.
    Edited by: sabre150 on Mar 17, 2009 11:48 AM                                                                                                                                                                                                                                                               

  • How to replace single font with combined font quickly in Framemaker 12

    Why there is no combined font can be selected in "Replace With" field?

    Yes, but some one Has been achieved
    only haveProvided a illustrate
    http://images.missyuan.com/attachments/day_131226/20131226_705ae5b52765c61bdfa18FN2NfkOUbU n.gif
    I  did not understand, why fonts management  did not like the indesign, They are all belong to adobe

  • How do I replace quotation marks with double angle quotation marks, still keeping the word in the mi

    Hi,
    Does anyone know how to replace quotation marks with double angle quotation marks, still keeping the word in the middle?
    For example: I search for a word with quotation marks by typing in: (")(\w+)(") in the "find what" field. What should I type in the "change to" field?
    I'd be very grateful for answers!

    It's much simpler: find " and replace with " (make sure that 'Use typographer's quotes' is enabled in the preferences).
    Peter

  • Single slash to Double Slash Convertion

    hi all,
    i want to replace single slash (\) by double slash(
    ) in a path , ex :
    ...\..\.. should become
    ..   when i m trying to do so,it takes it as an escape sequence character. Can anyone help me plz

    Use double-slash to represent the single slash and a quadruple slash to represent the double-slash.
    stringreplace( Transaction.PropertyName , "
    Above statement translates to replace "\" with "
    " when the expression in the Link Editor is evaluated.
    The other option is to create a local property called Slash with a default value of \ in the property editor.
    Your expression would look like:
    stringreplace( Transaction.PropertyName , Local.Slash , Local.Slash & Local.Slash )
    Of course, you could use another local property of double-slash if you wish.
    Hope this helps.
    Cheers,
    Jai.

  • How to replace double quotes with a single quote in a string ?

    Hi All:
    Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
    My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
    Thanks,
    Dima.

    Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
    SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
    REPLACE(
    STN. 'A'{code}
    Nicoals.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to replace multiple occurences of space in a string to a single space?

    How to replace multiple occurences of space in a string to a single space?

    Hi,
    try this code.
    data : string1(50) type c,
              flag(1) type c,
              dummy(50) type c,
              i type i,
              len type i.
    string1 = 'HI  READ    THIS'.
    len = strlen( string1 ).
    do len times.
    if string1+i(1) = ' '.
    flag = 'X'.
    else.
    if flag = 'X'.
    concatenate dummy string1+i(1) into dummy separated by space.
    clear flag.
    else.
    concatenate dummy string1+i(1) into dummy.
    endif.
    endif.
    i = i + 1.
    enddo.
    write : / string1.
    write : / dummy.

  • Please Help!  I have been writing using - Pages - app for years.  I still can not figure out how to make single spaces between paragraphs.  Pages automatically double spaces between paragraphs.

    I have been writing on - Pages- app for several years.  Pages automatically uses double space between paragraphs. I can not figure out how to make single space between paragraphs. Tried everything.  Please help!  

    Pages User Guide >  http://manuals.info.apple.com/en_US/Pages_UserGuide.pdf
    Open the user guide then press Command + F on your keyboard.
    Type line spacing in the search field top right corner of that window.

  • Server 2008 R2 Robocopy Failure with Double Backslash "\\" in file path

    Hi,
    I am doing a large Robocopy for a customer of mine that is reading from a DVD source and copying across the WAN, potentially running for multiple months.  The RoboCopy is running as a scheduled task on Windows 2008 R2 (target) and copying from a Windows
    2000 source.  I have kicked the process off twice, and each time it appears to function for a day or so and then begins to seemingly get stuck in a loop in which it is perpetually failing due to an attempt to append double backslashes "\\" to
    the file path.  I have been researching potential causes of the issue online and have come up empty.  Any assistance with this would be GREATLY appreciated.
    Batch Script Robocopy Commands - 150 commands total, each using the same switches (note that /MT is not being used since it negates /NP and I have to verify the copy success with logfiles of a manageable size)
    C:\Windows\System32\Robocopy.exe \\hqsa0400\ArchiveXtender\VolumeName F:\VolumeName /E /Z /R:15 /W:60 /NFL /NDL /NP /LOG:E:\JukeboxRobocopy\JukeboxOSM_Copy_VolumeName.log
    Example of Errors:
    2014/02/05 15:49:05 ERROR 123 (0x0000007B) Creating Destination Directory F:\VolumeName\20060130\\105413\
    The filename, directory name, or volume label syntax is incorrect.
    2014/02/05 15:52:05 ERROR 161 (0x000000A1) Scanning Source Directory \\hqsa0400\ArchiveXtender\VolumeName\20060130\\105513\
    The specified path is invalid.Waiting 60 seconds... Retrying...
    Thanks

    This has started to happen to me on Windows 7
    Sept 2013 script works fine.
    Feb 2014 stopped working, keeps adding an extra \ to the folder path and so fails.
    Nothing has changed with my script, or setup??
    Robocopy "E:\My Music" "Z:\1MC" *.mp3 /MIR /FFT  /XJ /Z /XA:H /W:1 /r:1 /v
    Example output
                        0 E:\My Music (Download)\Download Music\
     *EXTRA Dir        -1 Z:\2DW\\
       *EXTRA File      21508 .DS_Store
    2014/02/26 22:16:40 ERROR 161 (0x000000A1) Deleting Extra File Z:\2DW\\.DS_Store
    The specified path is invalid.

  • How to handle both single click and double click from mouse

    hey,
    I looked in past threads and didn't get a proper answer for capturing both single and double click from the mouse.
    in most applications the single click action does not interfere with the double click action, for example in a text editor, single click sets the cursor in between the text, double click marks a word, triple click marks a sentence, they do not bother each other, they all can happen first the single then the double and then the triple, but what if i have a very distinct action for each of the actions, the e.getClickCount() returns every time the number of clicks and if i use
    if(e.getClickCount()==1)
        doSingleClick();
    if(e.getClickCount()==2)
        doDoubleClick();it will always do first the single click and then the double click, which works fine with the example i gave, but not with what i want to do, so i was thinking to over come this that i will use another thread to run my tasks if dt has past since the last click and by the last click counts to perform the correct action and go to sleep until the next mouse click notify it, what do you think?
    run this to get what i mean...
    package blah;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MouseClickTest {
         static long previousTime = System.currentTimeMillis();
         public static void main(String[] args) {
              JPanel panel = new JPanel();
              JButton component = new JButton("Hit me, please");
              component.addMouseListener(new MouseAdapter(){
                   public void mouseClicked(MouseEvent me){
                        if(me.getClickCount()==1)
                             System.out.println("Now I will do single click action");
                        if(me.getClickCount()==2)
                             System.out.println("Now I will do DOUBLE click action");
    //                    System.out.println("Click count: " + me.getClickCount());
              panel.add(component);
              Launcher.launch(panel);
    package blah;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Launcher {
         public static JFrame launch (Container contents, String title, Color backgroundColor) {
              JFrame frame = new JFrame (title);
              if (backgroundColor != null) {
                   frame.setBackground (backgroundColor);
                   contents.setBackground (backgroundColor);
              } else {
                   frame.setBackground (contents.getBackground());
              frame.getContentPane().add (contents, BorderLayout.CENTER);
              frame.pack();
              frame.addWindowListener (new WindowAdapter() {
                   public void windowClosing (WindowEvent e) {
                        System.exit (0);
              frame.setVisible (true);
              return frame;
         public static JFrame launch (Container contents, String title)      {
              return launch (contents, title, null);
         public static JFrame launch (Container contents, Color backgroundColor) {
              return launch (contents, contents.getClass().getName(), backgroundColor);
         public static JFrame launch (Container contents) {
              return launch (contents, contents.getClass().getName());
    }

    Read my comments and solution in this posting; [http://forums.sun.com/thread.jspa?forumID=57&threadID=705244]
    and then choose a better design for your application.

  • Leopard Registering Single Clicks as Double Clicks

    I have a terrible problem under 10.5.1 with the system registering about 40% of my single clicks as double clicks. It seems to be getting worse, as well. I thought it was an issue with the mouse on my Wacom tablet or with the Wacom driver, but in trying to troubleshoot it I found I had the same problem when using my original Apple mouse.
    It's extremely problematic. For example, I've customized my Finder toolbar to include the delete icon. However, if I click the delete icon and the system registers it as a double click, it will delete not only the file I intended, but it's parent directory. Is anyone else experiencing this?

    I have the same problem. I have concluded that it is a software problem either with OS X or some third party software on the computer.
    I originally thought it was a problem with Logitech's control center as that was the mouse I was having problems with. However, I recently replaced that mouse and uninstalled the logitech software and am still having problems with my new mouse from a different vendor. All the while, the trackpad will still register single clicks as double clicks.
    In my observations I found that once I restart the computer, single clicks will be registered as normal for the first few minutes of computer use. After that, any time the mouse is clicked more than once without being moved, no matter how much time has passed, it will register the subsequent clicks as double/triple/etc. clicks. So if, for example, I were to click an application icon once, not move the mouse, come back a day later and click again, it will double click. I also found that if the mouse is moved ever so slightly, it might still register as a double click.
    Additionally, if I am scrolling through any window but don't move the mouse, it will register the subsequent clicks as double clicks, even when you are clicking on a different item. An example of this is if I am scrolling down a finder window with a lot of files in column view, click on a file to see it's icon preview, then scroll down without moving the mouse and click on another file, it will register as a double click and launch that item.
    Other observations: I was having this problem in the early days of my OS install, so I went ahead and reinstalled the system. The problem came back in a day or so and I can't pinpoint it to any one piece of software that has been installed. I'm wondering if it is an OS issue.

  • String value changes single quote ' to double quote "

    I am creating a list with different bill codes within single
    quotes as follows
    <cfset corlist = " '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ' ">
    when I do an output
    for
    <cfoutput>AND idbillcode IN ( #corlist
    #)</cfoutput>
    I get the values as follows
    AND idbillcode IN ( '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ')
    However when I put the same string within a cfquery the
    single quotes get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800 '',''1950 '',''7001 '') which throws an error.
    Anybody has any clues.
    Thanks.

    However when I put the same string within a cfquery the
    single quotes
    get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800
    '',''1950
    '',''7001 '') which throws an error.
    Anybody has any clues.
    That is ColdFusion escaping the single quotes, by doubling
    them so that
    you can search for strings such as "singhpk's code does not
    work".
    (Note the single quote/apostrophe that would normally break
    this string
    if it was not escaped.
    To tell CF not to do this, one uses the
    preserveSingleQuotes() function.
    The documentation has all the details.

  • How to replace hard drive and transfer everything over?

    I've looked everywhere but am unable to find a definitive guide on how to do this.
    Currently I have an early 2011 MBP that came with Snow Leopard and upgraded to Lion later. It has an HDD and I want to replace it with an SSD and transfer everything over to the SSD. Considering Lion created a Recovery partition (and there is also an EFI partition), I'm confused on how to do this the best way to basically copy my current hard drive to the new SSD.
    The best I've figured out is to connect the SSD with a SATA-USB cable, use the Lion Recovery Disk Assistant ( http://support.apple.com/kb/dl1433 ) to create a Recovery partition on the new SSD, then, booting into Recovery, install Lion on the new SSD, and then use Migration Assistant to transfer all my files over.
    Is there a simpler or better-explained way to basically copy my current hard drive over to a new SSD and then remove the HDD and use the SSD?

    How to replace or upgrade a drive in a laptop
    Step One: Repair the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Step Two: Remove the old drive and install the new drive.  Place the old drive in an external USB enclosure.  You can buy one at OWC who is also a good vendor for drives.
    Step Three: Boot from the external drive.  Restart the computer and after the chime press and hold down the OPTION key until the boot manager appears.  Select the icon for the external drive then click on the downward pointing arrow button.
    Step Four: New Hard Drive Preparation
    1.  Open Disk Utility in your Utilities folder.
    2. After DU loads select your new hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID (for Intel Macs) or APM (for PPC Macs) then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Step Five: Clone the old drive to the new drive
    1. Open Disk Utility from the Utilities folder.
    2. Select the destination volume from the left side list.
    3. Click on the Restore tab in the DU main window.
    4. Check the box labeled Erase destination.
    5. Select the destination volume from the left side list and drag it to the Destination entry field.
    6. Select the source volume from the left side list and drag it to the Source entry field.
    7. Double-check you got it right, then click on the Restore button.
    Destination means the new internal drive. Source means the old external drive.
    Step Six: Open the Startup Disk preferences and select the new internal volume.  Click on the Restart button.  You should boot from the new drive.  Eject the external drive and disconnect it from the computer.

  • How to enable single window mode?

    *how to enable single window mode in the latest version of Safari?*
    browser opens up some links in new windows and it is very inconvenient
    Message was edited by: wolfxr

    All that you describe is the standard setting them I have long found, but they do not bring any results. What is interesting - parameter "TargetedClicksCreateTabs" in a state of "true" which is processed in the Mac version, broken in the Windows-based version if it is to register the file C: \ Program Files \ Safari \ Safari.resources \ Defaults.plist a file stored in the folder C: \ Documents and Settings \ Admin \ Application Data \ Apple Computer \ Preferences \ com.apple.Safari.plist scrambled to change it theoretically impossible, but if you replace it with THIS file, then it can be set, but the parameter "TargetedClicksCreateTabs" still not working

Maybe you are looking for

  • Protected View Error "The file is corrupt and cannot be opened"

    All  I have a problem with Protected View in Office 2010 on Windows 7. Symptom:  When downloading a file from the Internet, the file will not open if launched directly from the source location, or saved locally and then opened.  This is impacting bot

  • Bridge Searches and Keyword suggestions

    In Bridge CS3, changing the search target, eg from filename to keyword, dumps any search items already entered and replaces it with 'Enter Text'. This is seriously irritating if you have already entered the search string and have the wrong field sele

  • I cannot download all of my available downloads

    I receive the error: Unable to check for available downloads. The network connection was reset. I can download the files that have been available to me for a while, which i dont want to download, but the files I am looking for (application updates an

  • G5 losing all Firewire ports??

    Just turned on my Mac G5 Dual 2.3Ghz which has been running perfect before and i think my firewire ports on the machine have been disabled?? I have an External FW800 Hard drive with sample libraries, and the FW400 MOTU 828mk2 soundcard. For some reas

  • IWeb Publishing url

    When I publish my home page on my .Mac site I have my site address as : http://web.mac.com/groups.ajbraun/iWeb/Site/Welcome.html But when it finishes publishing it always inserts the following 90D0FC3C-1D6F-49FE-83BC-4762AB7CB77E so now shows : http: