Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6472683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:22:33+00:00 2026-05-25T06:22:33+00:00

Java class File has 4 constructors: File(File parent, String child) Creates a new File

  • 0

Java class File has 4 constructors:

  • File(File parent, String child)
    Creates a new File instance from a parent abstract pathname and
    a child pathname string.

  • File(String pathname)
    Creates a new File instance by converting the given pathname string
    into an abstract pathname.

  • File(String parent, String child)
    Creates a new File instance from a parent pathname string and a
    child pathname string.

  • File(URI uri)
    Creates a new File instance by converting the given file: URI into
    an abstract pathname.

When I do:

File f=new File("myfile.txt");

Does a physical file on disk get created? Or does JVM make call to OS or does this only create an object inside JVM?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:22:34+00:00Added an answer on May 25, 2026 at 6:22 am

    No, creating a new File object does not create a file on the file system. In particular, you can create File objects which refer to paths (and even drives on Windows) which don’t exist.

    The constructors do ask the underlying file system representation to perform some sort of normalization operations if possible, but this doesn’t require the file to be present. As an example of the normalization, consider this code running on Windows:

    File f = new File("c:\\a/b\\c/d.txt");
    System.out.println(f);
    

    This prints

    c:\a\b\c\d.txt
    

    showing that the forward slashes have been normalized to backslashes – but the a, b, and c directories don’t actually exist. I believe the normalization is more to do with the operating system naming scheme rather than any actual resources – I don’t believe it even looks on disk to see if the file exists.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The one class per file rule in Java has me a bit confused. I
What are the consequences of running a Java class file compiled in JDK 1.4.2
If I have a Java source file (*.java) or a class file (*.class), how
I'm trying to figure out what a Java applet's class file is doing under
I am trying to write a Java class to extract a large zip file
To my knowledge, Java's File class does not support to change the file's permission
I have a Java file TestThis.java like the following: class A { public void
For example, java.io.File is just a concrete class. My replacement for it supports resolving
In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String"
I'm trying to load a java .class file dynamically and call it by reflection.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.