Article View: borland.public.jbuilder.java.language
Article #18874Re: Backslash Escape Character
From: Clint Brewer
Date: Thu, 09 Apr 1998 00:00
Date: Thu, 09 Apr 1998 00:00
46 lines
1989 bytes
1989 bytes
Jack Frosch wrote:
>
> I'm wanting to concatenate a filename string to a directory string, both
> of which came from a Filer selection. For instance,
>
> //*******************************************
> String sFileDir, sFileName;
>
> dlg_File = new Filer(this, "Select File");
> dlg_File.show();
>
> sFileDir = dlg_File.getDirectory();
> sFileName = dlg_File.getFile();
>
> if (sFileName.length() > 0)
> // Sidebar: Is this the best way to check if a file was selected?
> {
> sle_FilePath.setText(sFileDir + "\\" + sFileName); // show
> path+file in Field control <---Line13
> File hdlFile = new File(sFileDir, sFileName);
> // do something with File
> }
> //*******************************************
>
> Unfortunately, the resulting text in sle_FilePath looks like:
> "c:\winnt\temp\\file.txt" If I change the expression in Line 13 to
> (sFileDir + "\" + sFileName), the compiler chokes, saying I have an
> unclosed quote.
>
> So how do I add a backslash string to another string?
>
> TIA.
>
> Jack
Hello Jack,
I think what is actually happening, is that the sFileDir actually
includes the backslash that you are trying to add. Your are doing it
correctly, and it's doing exactly what you told it to do....take this
string and put a backslash on the end, hence the two bckslashes. If you
just do: sFileDir + sFileName it should work.
hope this helps,
Clint Brewer
Technical Details
Message-ID:
<352D7FFD.6AE1@borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<352C344C.18E9FBFD@swbell.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,5f23d90b3c517ba1 X-Google-Attributes: gidf74b3,public From: Clint Brewer <supportinfo@borland.com> Subject: Re: Backslash Escape Character Date: 1998/04/09 Message-ID: <352D7FFD.6AE1@borland.com> X-Deja-AN: 342604309 Content-Transfer-Encoding: 7bit References: <352C344C.18E9FBFD@swbell.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Borland International Newsgroups: borland.public.jbuilder.java.language