Re: why construct file with "", the path of the file return "/"?



junzhang1983@xxxxxxxxx wrote:
l am a little puzzled, why the file's behavior like this:

File fl = new File("","1.txt");
System.out.println(fl.getName());
System.out.println(fl.getParent());
System.out.println(fl.getPath());
System.out.println(fl.getAbsolutePath());
try {
System.out.println(fl.getCanonicalPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

the output is:
1.txt
\
\1.txt
D:\1.txt
D:\1.txt

why "" path, java process it as "/"?

From the docs

"If parent is the empty abstract pathname then the new File instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory."

--

Knute Johnson
email s/nospam/knute/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
.



Relevant Pages

  • Re: What is "Darwinist Morality"?
    ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ... utterly containing round no matter how my area. ... Linette when the dead shops give against the multiple obelisk. ...
    (rec.pyrotechnics)
  • Re: How Do These Tamiya Weathering Kits Differ from Dry Brushing?
    ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ... I've finished one 54mm Airfix figure and recommend using acrylics. ... As for the horses, you'd be hard pushed to beat artists oils ...
    (rec.models.scale)
  • Re: printing tools
    ... >> I've been generating PDF reports for years now under Linux ... Cada una es buena para lo que es, ... >> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... >> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.databases.pick)
  • Re: OT: Cliff WMDs
    ... Dont act like you give a fuck about our men and women in uniform, ... Just go back to being a terrorist appeaqsing coward and leave the work to ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (alt.machines.cnc)
  • Re: OT: I tried Sander. I tried Paul. I tried Jenn. Sorry!
    ... a long time believer of saying something makes it so, ... He is merely pretending to be a loser. ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (rec.audio.opinion)