Skip to content
Study Hall
Lesson 3 of 3Intro to Computers
Unit 1 · Lesson 3 of 3

Files, Folders and a Workspace That Works

Paths, file types, naming that sorts, project folder structure, backups, version control, compression and a workstation that does not hurt to sit at.

10 min read12 practice questionsAsk AI about this →

Key things to remember

  1. 1An absolute path starts at the root and always means the same file; a relative path starts at the current working directory and survives moving the project.
  2. 2In a relative path, . is the current folder and .. is the parent folder.
  3. 3A file's real type is determined by its content (its signature bytes), not by its extension — renaming converts nothing.
  4. 4Name files so they sort: ISO dates (YYYY-MM-DD), zero-padded numbers, no spaces.
  5. 53-2-1 backup: three copies, on two kinds of media, with one offsite.
  6. 6Lossless compression restores the original exactly; lossy compression discards detail permanently.

Every programmer eventually loses work. Usually it is not dramatic — no hard drive explodes. It is a file overwritten by a worse version, a folder of forty files all called something like assignment, or an evening spent trying to remember which of six copies actually compiled. None of that is bad luck. It is the predictable result of having no system. This topic is the system: how the computer organizes files, how you should name and arrange yours, how to make losing work impossible rather than unlikely, and how to sit at the machine for three hours without your wrists hurting.

File systems, directories and paths

A file system is the scheme the operating system uses to lay out files on a drive and remember where each one is: NTFS on Windows, APFS on macOS, ext4 on most Linux systems, exFAT on memory cards meant to work with everything. On top of that scheme sits a tree of directories (folders), and a path is the set of directions from some starting point to a particular file.

AAbsolute path
  • Starts at the root of the drive or system
  • Windows: C:\Users\sam\ics\Sorter.java
  • macOS or Linux: /home/sam/ics/Sorter.java
  • Always means the same file, from anywhere
  • Breaks the moment the project moves to another computer
BRelative path
  • Starts at the current working directory
  • src/Sorter.java means "down into src from here"
  • ../data/scores.txt means "up one level, then into data"
  • . is here, .. is the parent folder
  • Survives moving the whole project folder, which is why code uses it
Why your program cannot find its data file
A relative path is resolved from the working directory of the running program, which is not always the folder the source file lives in. If a Java program opens scores.txt and gets a file-not-found error, print the working directory first and see where the program actually thinks it is standing before you change the path.

Extensions, and what really decides a file's type

The part after the last dot is a hint for the operating system about which program should open the file. It is only a hint. What actually determines the type is the content, and most formats start with a signature — a fixed sequence of bytes near the beginning. A PNG begins with a specific eight-byte header; a ZIP archive begins with the letters PK. Renaming a file from .png to .jpg changes nothing about the pixels inside it; it just makes programs guess wrong. Converting a file means re-encoding the data, which is a different operation entirely.

ExtensionWhat it holdsWorth knowing
.javaJava source code, plain textThe file name must match the public class name exactly, including capitals
.classCompiled Java bytecodeGenerated by the compiler; never edit it, and it can be deleted and rebuilt
.txt / .csvPlain text; CSV is text with commas as column separatorsOpens in anything, compresses very well, safe to read in code
.png / .jpgImage dataPNG is lossless and good for screenshots; JPG is lossy and good for photos
.zipA compressed archive of many filesLossless — what comes out is byte-for-byte what went in
.pdfA fixed-layout documentLooks the same everywhere, which is why it is the usual submission format
// File must be named Sorter.java - capital S, exact spelling.
public class Sorter {
    public static void main(String[] args) {
        System.out.println("ready");
    }
}
// Saved as sorter.java, the compiler reports:
//   class Sorter is public, should be declared in a file named Sorter.java
In Java the file name is part of the program, not a label on it.

A folder structure for a coding project

Separate the things you write from the things the computer generates, and separate both from the data. That one rule gives a structure you can back up intelligently, because you only truly need to keep the parts you wrote — everything in the output folder can be rebuilt from them in seconds.

ics-projects/
├─ unit03-arrays/
│  ├─ src/            <- .java files you wrote
│  │  ├─ Sorter.java
│  │  └─ Stats.java
│  ├─ out/            <- .class files the compiler made (never back this up)
│  ├─ data/           <- input files the program reads
│  │  └─ scores.txt
│  ├─ docs/           <- planning notes, flowcharts, test plan
│  └─ README.txt      <- what it does and how to run it
└─ unit04-methods/
   └─ src/
      └─ Menu.java
Source, output, data and documentation each get their own folder.

Backups: the 3-2-1 rule

A file that exists in one place does not really exist. Drives fail without warning, laptops get stolen, ransomware encrypts everything a user account can write to, and the most common disaster of all is a person deleting or overwriting the wrong file. The 3-2-1 rule is the standard professional answer, and it is worth following exactly because each number defends against a different failure.

  1. Three copies of anything you care about — the working copy plus two backups. One backup can fail silently; two failing at the same time is far less likely.
  2. Two different kinds of media — for example the internal SSD plus an external drive. If one type has a manufacturing flaw or a controller failure, the other is unaffected.
  3. One copy offsite — cloud storage or a drive kept somewhere else entirely. A fire, flood or theft takes everything in one room, no matter how many drives are in it.
Sync is not backup
A folder that syncs to the cloud copies your mistakes as fast as it copies your work. Delete a file or save a broken version and the cloud faithfully mirrors that within seconds. Sync protects against losing the device; only versioning or a separate backup protects against you. Check that your cloud service keeps file version history, and learn where to find it before you need it.

Version control, and why final_final_v3 fails

Copying a file before changing it is a real instinct and a reasonable one — you want to be able to go back. The problem is that manual copies scale terribly. After a week you have Sorter.java, Sorter_backup.java, Sorter_v2.java, Sorter_final.java and Sorter_final_v3.java, and nothing records which one compiled, what changed between them, or why. Sorting by date only tells you which was touched last, not which was good.

AManual copies
  • File names carry the version, badly
  • No record of what changed or why
  • Merging two people's edits means copying by hand
  • Ambiguous ordering: which is newer, final or v3?
  • Every copy is a full duplicate of the whole file
BVersion control (for example Git)
  • One current file; history is stored separately
  • Each commit carries a message explaining the change
  • Any earlier state can be restored exactly
  • A diff shows precisely which lines changed
  • Branches let you try an idea without risking the working version

At a beginner level you do not need to master branching and merging. What you need is the habit: save a checkpoint whenever something works, write one honest sentence about what changed, and stop renaming files to record versions. Two commits named "reads the file and prints the average" and "fixed the off-by-one in the loop bound" are worth more than twenty files called final.

Compression and archives

Compression finds redundancy and stores it once. Lossless compression (ZIP, PNG, FLAC) rebuilds the original byte for byte, which is essential for code and documents — a program with one bit wrong does not compile. Lossy compression (JPEG, MP3, H.264) permanently discards detail people are unlikely to notice, achieving far smaller files at the cost of never getting that detail back. Archiving a project folder into one ZIP also has a practical benefit that has nothing to do with size: it keeps the folder structure intact when a submission system would otherwise flatten it.

Why zipping photos barely helps
Text and source code compress enormously because they are full of repetition — a 250 MB folder of Java files can drop below 60 MB. A JPEG is already lossily compressed, so almost all the redundancy is gone and a ZIP of photos shrinks by a percent or two at best. That is not a fault in the ZIP; there is simply nothing left to remove.

Setting up a workstation you can actually sit at

Programming means long stretches in one position, which is exactly the pattern that produces sore wrists, a stiff neck and tired eyes. None of these come from one bad session; they build up over months of small misalignments. Fixing the setup costs nothing and takes five minutes.

Set up the workstation so your body stays in neutral angles.eye line50–70 cm123451screen top = eye level2elbows about 90°3knees about 90°4feet flat on the floor5wrists straight, levelThe 20-20-20 ruleevery 20 minutes,look 20 feet (6 m) awayfor 20 secondsSet the chair first, then the desk, then the screen.
Fig 1Screen at eye level, elbows near a right angle, wrists straight, feet flat.
  • Screen — top of the display at or just below eye level, about an arm's length away. A screen that is too low pulls your head forward, and your neck carries that weight all day.
  • Chair and desk — elbows near a right angle with the forearms roughly parallel to the floor, shoulders relaxed, lower back supported. If your feet do not sit flat, use a footrest rather than dangling.
  • Keyboard and mouse — directly in front of you, close enough that your upper arms hang naturally. Keep wrists straight and floating rather than resting bent on the desk edge while typing.
  • Eyes — follow the 20-20-20 guideline: every 20 minutes look at something about 20 feet (6 m) away for 20 seconds, which lets the focusing muscles relax. Position the screen so windows and lights are to the side, never directly behind or in front of it.
  • Movement — stand up and move every 30 to 45 minutes. The best posture is the next one; no single position is healthy for three straight hours.
  • Cables and power — keep cables out of walkways, do not daisy-chain power bars, and keep drinks away from the keyboard. Most workstation damage is mechanical, not electronic.

Worked examples

Reveal one step at a time and try to beat it to the next line.

Example 1
The working directory is ics-projects/unit03-arrays/src. Write the relative path to scores.txt in unit03-arrays/data, and to Menu.java in unit04-methods/src.
Example 2
A folder holds: Mar 9 notes.txt, lab1.java, lab12.java, lab2.java, essay FINAL (2).docx. Rename them to a convention that sorts correctly and explain each change.
Example 3
A student keeps all coursework in one folder on a laptop, synced to a cloud drive. Assess this against the 3-2-1 rule and fix the gaps.
Example 4
A 250 MB project folder compresses to a 58 MB ZIP file. Calculate the percentage reduction and explain why a folder of photos would not behave this way.

Where marks get lost

  • Renaming a file's extension and believing the format changed. The bytes inside are untouched; only the operating system's guess about which program to use has changed.
  • Naming Java files inconsistently with the class inside them — sorter.java holding public class Sorter will not compile.
  • Writing dates as 9-Mar-2026 or 03/09/2026 in file names, so the folder sorts alphabetically by month or ambiguously between day and month order.
  • Forgetting to zero-pad numbers, so lab10 sorts before lab2 and the whole folder reads out of order.
  • Treating a synced cloud folder as a backup. It mirrors deletions and bad saves just as quickly as good work.
  • Recording versions by copying files — Sorter_final_v3.java stores no record of what changed or which version actually worked.

Flashcards 10

Absolute vs relative path
What do . and .. mean in a path?
What really determines a file's type?
Why write dates as YYYY-MM-DD in file names?
+ 6 more

Practice

1
The working directory is project/src. Which relative path reaches project/data/input.txt?
2
A student renames photo.png to photo.jpg. What has actually changed?
3
Put these file names in the order a computer would sort them alphabetically.
  1. 1lab3.java
  2. 2lab20.java
  3. 3lab2.java
  4. 4lab1.java
  5. 5lab10.java
4
State the 3-2-1 backup rule in the form "3 ___, 2 ___, 1 ___".
5
A 400 MB folder of source code compresses to a 72 MB ZIP. What is the percentage reduction in size?
%
6
Why is keeping Sorter.java, Sorter_v2.java and Sorter_final_v3.java worse than using version control?
7
In a relative path, what does .. refer to?
8
Which workstation adjustment most directly reduces neck strain?
9
Match each file extension to what it contains.
.java
.class
.csv
.zip
10
A project folder is zipped for submission mainly because:
11
A Java file contains public class BankAccount. What must the file be named?
12
Which statement about compression is correct?

Spot a mistake on this page? Let us know