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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:28:30+00:00 2026-05-16T11:28:30+00:00

FileWriter outFile = null; try { outFile = new FileWriter(member.txt); } catch (IOException e)

  • 0
        FileWriter outFile = null;
        try {
            outFile = new FileWriter("member.txt");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
out.println("test");

Running that command, where is the member.txt ? I am using windows vista. UAC enabled so when I run it, I don’t think it’s writing to the txt file. txt file is created however, but it’s empty.

  • 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-16T11:28:30+00:00Added an answer on May 16, 2026 at 11:28 am

    Relative paths in Java IO are relative to current working directory. In Eclipse, that’s usually the project root. You’re also writing to out instead of outFile. Here’s a minor rewrite:

        File file = new File("member.txt");
        FileWriter writer = null;
        try {
            writer = new FileWriter(file);
            writer.write("test");
        } catch (IOException e) {
            e.printStackTrace(); // I'd rather declare method with throws IOException and omit this catch.
        } finally {
            if (writer != null) try { writer.close(); } catch (IOException ignore) {}
        }
        System.out.printf("File is located at %s%n", file.getAbsolutePath());
    

    Closing is mandatory since it flushes the written data into the file and releases the file lock.

    Needless to say that it’s a poor practice to use relative paths in Java IO. If you can, rather make use of the classpath. ClassLoader#getResource(), getResourceAsStream() and so on.

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

Sidebar

Related Questions

try{ private fileWriter= new PrintWriter(new FileWriter(file.txt)); fileWriter.print(hello world); System.out.println(file written); fileWriter.close(); } catch (IOException
here is my code try { fstream = new FileWriter(/Applications/AirDrop/contacts.txt); BufferedWriter out = new
FileWriter f; try { f = new FileWriter(Environment.getExternalStorageDirectory()+ /Text/o1+.txt); f.write(Hello World); f.flush(); f.close(); }
try { File file = new File(sample.txt); FileWriter fw = new FileWriter(file,true); fw.append('d'); fw.write(100);
public static void getMembers(WebDriver driver, String outname){ FileWriter outFile = null; try { outFile
I am using: PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(test.txt),1024*1024*500)) to write a large
this code is correct?? String note = text.txt; FileWriter file = new FileWriter(note); Scanner
At the moment I have this: try{ // Create file FileWriter fstream = new
Please look through code below: // A.class File file = new File(blah.txt); FileWriter fileWriter
The following line FileWriter fw = new FileWriter(/log0.txt); throws: java.io.FileNotFoundException: /log0.txt (Read-only file system)

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.