Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.westnet.com.au!news.westnet.com.au.POSTED!not-for-mail NNTP-Posting-Date: Sun, 24 Jun 2012 13:02:08 -0500 From: "Qu0ll" Newsgroups: comp.lang.java.programmer References: In-Reply-To: Subject: Re: Local vs. network file Date: Mon, 25 Jun 2012 04:01:13 +1000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 15.4.3555.308 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3555.308 Message-ID: Lines: 57 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 124.149.34.27 X-Trace: sv3-vdU3tIKDyjYhrSjAjYJrJt1V/sZPm4AT7ltkVupWT+hRvrdO24bqp0EhwloiuHb3j0bDD1CZTMNRxhk!y7IfJBRGjKpSoH/uk744zWKX+GugQqYIoh9JnCG1rL17eCU0pKrZlYL4BwhlsxkqYEdGvECj4KVl!ulrxRIrqdHOGWihW8OL7 X-Complaints-To: abuse@westnet.com.au X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3766 Xref: csiph.com comp.lang.java.programmer:15562 Sorry about the lack of indentation, reply at the end... "Peter Duniho" wrote in message news:nb1dv4z3gq48.15acrjvtu4vh2.dlg@40tude.net... On Mon, 25 Jun 2012 03:24:22 +1000, Qu0ll wrote: > "Robert Klemme" wrote in message news:a4ov8oF930U1@mid.individual.net... > > On 24.06.2012 18:18, Qu0ll wrote: >>> Is it possible to determine if a given String contains the path of a >>> file on a network drive (versus a local file) in Java 7? >> >> Yes. > > OK, thanks for the confirmation. How is it done? Actually, I doubt you can do this in a platform-independent way. Even on Windows, a UNC path (which is normally used to specify a network path) can refer to a local drive and a drive-letter path can refer to a network location. You need to use platform-specific calls to tell the difference. I'm less familiar with the *nix family, but my recollection is that because of its even-more-generalized file system implementation, the path itself is of no use. You'd also have to use lower-level OS-specific calls to get that information. That said, while it's true that there can be somewhat different i/o characteristics between local and network files, I'm not convinced a program should attempt to concern itself with them. As networks become faster and faster, and more and more reliable, network-specific restrictions in a program are much less appropriate, and at the same time while delays and errors on local drives are rare, they can and do occur and a program should handle them correctly. Perhaps if you explain why it is you believe you need to know the difference between a local and a network path, you can get better advice that addresses your _actual_ problem, rather than does or does not solve some specific method you've already selected to deal with that problem. ---------------------------------- Thanks Peter. I have a requirement to limit a program which is licensed as "stand alone" to not be run from a network location so I figured if I could tell whether the launch directory was a network share then I could block it. Is there another way I could implement this? -- And loving it, -Qu0ll (Rare, not extinct) _________________________________________________ Qu0llSixFour@gmail.com [Replace the "SixFour" with numbers to email me]