Programming

Cards (50)

  • Exception
    An event that occurs during the execution of a program that disrupts the normal flow of instructions
  • Types of Storage Device
    • Volatile storage
    • Non-volatile storage
  • Volatile storage
    Temporary. Volatile values (stored in variables) are lost when the computer loses its power.
  • 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
  • Exception handling
    The process used to change the normal flow of code execution if a specified exception occurs
  • Categories of File
    • 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 like ASCII or Unicode.
  • 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.
  • The common characteristics of a text file and binary file are size, name, and date and time of creation.
  • Permanent files are 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)
  • To convert a relative path to an absolute path, the toAbsolutePath() method is used.
  • Arguments of the checkAccess() Method

    • None
    • READ
    • WRITE
    • EXECUTE
  • The delete() method of the Files class accepts a Path parameter and 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
  • The deleteIfExists() method can also be used to remove a file without encountering an exception if the file does not exist.
  • To retrieve useful information about a file, the readAttributes() method of the Files class is used.
  • BasicFileAttributes Methods
    • size()
    • creationTime()
    • lastModifiedTime()
    • compareTo()
  • Character
    The smallest useful piece of data. A character 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
    A file where each record 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.
  • Checked exceptions
    • ClassNotFoundException
    • IllegalAccessException
    • InstantiationException
    • NoSuchMethodException
  • 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)
  • StandardOpenOption Arguments

    • WRITE
    • APPEND
    • TRUNCATE_EXISTING
    • CREATE_NEW
    • CREATE
    • DELETE_ON_CLOSE
  • Common Methods of the BufferedReader Class
    • close()
    • read()
    • read(char[] buffer, int off, int len)
    • readLine()
    • skip(long n)