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 6565373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:05:10+00:00 2026-05-25T14:05:10+00:00

suppose I put a file a.txt in package com.xyz and the try access it

  • 0

suppose I put a file a.txt in package com.xyz and the try access it like following. Will it work?

Hi All,

          import com.xyz.*;
          public class Hello
          { 
            File f = new File("a.txt");
             ...
          }

It is not working for me. Is there any workaround?

  • 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-25T14:05:11+00:00Added an answer on May 25, 2026 at 2:05 pm

    Based on your responses to the comments above. If you are looking for a work around, just specify the path to the .txt file on the file system. Putting it in a package does not help.

    new File ("a.txt")

    looks for a file on the the file system and not within a package.

    Please also read the javadocs on File:
    http://download.oracle.com/javase/6/docs/api/java/io/File.html

    However I do not see the rationale in putting the file inside a package unless you would want to use it as a resource. In which case @jcomeau_ictx has the right solution

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

Sidebar

Related Questions

so suppose my server is located in http://www.example.com I then put a file file.exe
Suppose I declared an array as following: int myArr = [someSize]; Now I put
Suppose we have a example.exe file. we first put that file in a new
suppose i have the following in a text file (or dired buffer) open in
suppose this is my txt file: line1 line2 line3 line4 line5 im reading content
Suppose the following toyset (from a CSV file where column names are the keys
Possible Duplicate: How to put exe file in windows Startup Suppose I have built
I'm in xCode 4.2 using ARC and Storyboard (iOS 5). I suppose to put
Suppose I want to put objects that identify a server into a stl set
Supppose you are here http://domain.com/category/month/123 . What's the correct way to put a link

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.