hehe

Cards (42)

  • Volatile storage
    Temporary. Volatile values (stored in variables) are lost when the computer loses its power. The Random Access Memory (RAM) is being used when a Java program stores a value in a variable.
  • Non-volatile storage
    Permanent. A Java program that is saved on a disk uses a non-volatile storage.
  • Computer file
    A collection of data stored on a non-volatile device.
  • Types of files
    • Text file
    • Binary file
  • Text file
    Consists of data that can be read in a text editor. Data in a text file is encoded using a scheme. The most common schemes are ASCII and Unicode. Examples are program files and application files.
  • Binary file
    Contains data that is not encoded as text. This file has contents in binary format, which means they cannot be understood by viewing them in a text editor. Examples are images, music, and the .class extension files which are created after compiling Java programs.
  • The common characteristics of a text file and binary file are size, name, and date and time of creation.
  • Permanent files
    Commonly stored in the main directory or the root directory.
  • Folders or directories
    Used to organize stored files.
  • Path
    The complete list of the disk drive plus the hierarchy of directories in which the file is located.
  • In the Windows operating system, the backslash (\) is the path delimiter – the special character used to separate path components.
  • Path class
    Creates objects that contain information about files and directories, such as sizes, locations, creation dates, and is used to check whether a file or directory exists.
  • Files class
    Performs operations on files and directories, such as determining their attributes, creating input and output streams, and deleting them.
  • Absolute path
    A complete path; it does not require any other information to locate a file on a system.
  • Relative path
    Depends on other path information.
  • Path methods
    • toString()
    • getFileName()
    • getNameCount()
    • getName(int)
  • Converting a relative path to an absolute path

    Use the toAbsolutePath() method
  • checkAccess() method
    Verifies if a file exists and if a program can access it when needed
  • Arguments of the checkAccess() method

    • None
    • READ
    • WRITE
    • EXECUTE
  • delete() method
    Removes the last element (file or directory) in a path or throws an exception if the deletion is unsuccessful
  • Examples of exceptions
    • NoSuchFileException
    • DirectoryNotEmptyException
    • SecurityException
    • IOException
  • deleteIfExists() method
    Removes a file without encountering an exception if the file does not exist
  • readAttributes() method

    Retrieves useful information about a file
  • BasicFileAttributes methods
    • size()
    • creationTime()
    • lastModifiedTime()
    • compareTo()
  • Character
    The smallest useful piece of data, which can be any letter, number, or other special symbol (such as punctuation mark) that makes up data.
  • Field
    A group of characters that has some meaning.
  • Record
    A collection of fields that contain data about an entity.
  • File
    Consists of related records.
  • Sequential access file
    When each record in a file is accessed one after another in the order in which it was stored.
  • Comma-separated values
    Values in a record that are separated by commas.
  • Stream
    A flow of data. If the data is taken from a source (such as a file or the keyboard) and is delivered into a program, it is called an input stream. If the data is delivered from a program to a destination (such as a file or the screen), it is called an output stream.
  • Buffer
    A memory location into which you can write data, which you can read again later.
  • Flushing
    Clears any bytes that have been sent to a buffer for output but have not yet been displayed on a hardware device.
  • Input and Output Classes
    • InputStream
    • FileInputStream
    • BufferedInputStream
    • OutputStream
    • FileOutputStream
    • BufferedOutputStream
    • PrintStream
    • Reader
    • BufferedReader
    • BufferedWriter
  • Common methods of the OutputStream class
    • close()
    • flush()
    • write(byte[] b)
    • write(byte[] b, int off, int len)
  • newOutputStream() method

    Creates a writeable file
  • StandardOpenOption arguments

    • WRITE
    • APPEND
    • TRUNCATE_EXISTING
    • CREATE_NEW
    • CREATE
    • DELETE_ON_CLOSE
  • newInputStream() method

    Opens a file for reading
  • BufferedReader
    Reads a line of text from a character-input stream, buffering characters so reading is more efficient.
  • Common methods of the BufferedReader class
    • close()
    • read()
    • read(char[] buffer, int off, int len)
    • readLine()
    • skip(long n)