Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is IntelliJ java. Create a /data/ directory in your project directory. Write a program that creates and stores a test file in this directory.

This is IntelliJ java.

Create a /data/ directory in your project directory. Write a program that creates and stores a test file in this directory. FileWriter can take a filename as an argument. The filename can only be a file in your current directory. So you cant say new FileWriter fw = new FileWriter(/data/testing.txt);But, FileWriter can also take a File object as an argument, and a File object can store a path to a file elsewhere on your system (or even on a remote system).

Heres how to create a File object; File f = new File(/mydirectory/mysubdirectory/textfile.txt);

Assuming these directories exist, you can create and write that file in this location. The location is relative to the current directory. Ill leave it to you to put these pieces together.Notice that one file system uses forward slashes, and one uses backslashes, so you'll need to use the correct \ or / for your computer. Mac is also case-sensitive.[Note: You can also use absolute pathnames, for example

C:\program files\java\textfile.txt on Windows, or/users/admin/Documents/textfile.txt on a Unix-based system like Linux or Mac,

but if you do that, your program may not work on anyone else's computer! ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

15.2 Explain the costs associated with employee turnover.

Answered: 1 week ago