Question: So I'm trying to use a KeyBoardEvent honestly just for testing purposes.. what I'm doing does not seem to be working :/ Hopefully you guys can tell me where I'm derping. Thanks! 

```
package com.dillyg10.test.Keys;

import java.awt.Window;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Keys extends JPanel implements KeyListener  {
    private static final long serialVersionUID = 1L;

    public Keys(){

    }

    public static void registerEvent(Window w){
        w.setFocusTraversalKeysEnabled(false);
        w.setFocusable(true);
        w.addKeyListener(new Keys());
    }
    public void keyPressed(KeyEvent e) {
        System.out.println(KeyEvent.getKeyText(e.getKeyCode()));
    }
    public void keyReleased(KeyEvent e) {

    }
    public void keyTyped(KeyEvent e) {

    }
    public static void gui() {

        JFrame frame = new JFrame("Keys");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        registerEvent(new Window(frame));

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                gui();
            }
        });
     }
    }

```

This code is basically a test to determine if the keyboardevents work, i jsut print out the key when it's pressed.. but nothing is printed.

Answer: 
The point is that a file is like an array (just on disk). It occupies a fixed place on the disk.

If you have to insert something in the middle of an array, you have to move out the trailing elements, otherwise you will overwrite these. The same concept applies to files, you need to move out the trailing part of the file to insert something in the middle.

The one exception to this is when you need to overwrite a fixed size block of the file with a new block of the same size. Then it is perfectly fine to use fseek() and then just overwrite.
Of course you can edit a file in place:

```
import struct
RECSIZE = struct.calcsize('<i')

fp = open('name.txt', 'r+b')
fp.seek(132 * RECSIZE)   # go to record number 132
fp.write(struct.pack('<i', 42))
fp.seek(132 * RECSIZE)
assert struct.unpack('<i', fp.read(RECSIZE)) == 42

```

this also shows the most common reason for doing so and the limitations.