1/31
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
inner classes
have access to outer class members
Scanner (reading from files)
Scanner sc = new Scanner(new File("input.txt"));
package
namespace that organizes related classes and interfaces, like folders for Java files
import packageName.ClassName; // Import a single class
import packageName.*; // Import all classes in the package
ObjectInputStream (serialization)
ObjectInputStream in = new ObjectInputStream(new FileInputStream("obj.dat"));
MyClass obj = (MyClass) in.readObject();
ObjectOutputStream (serialization)
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("obj.dat"));
out.writeObject(myObject);
Formatter (writing formatted text to files)
Formatter fmt = new Formatter("output.txt");
Know how to open an output file and write data to it (write() method)
FileOutputStream fos = new FileOutputStream("output.txt");
fos.write(data);
Know how to open an input file and read data from it (read() method)
FileInputStream fis = new FileInputStream("input.txt");
int data = fis.read();
know what the '.class' file of a nested class looks like
Outer$Inner.class
anonymous inner class
used for one-time class definitions
-classpath
for specifying the locations of all classes or packages needed (for both javac and java)
-d
for specifying where the result of a javac command will be placed
transient
if an instance variable in an object is declared transient, it will be left out of the serialization
Serializable
a marker interface, an object can be serialized if its class implements this interface
serialization of objects
representing an object as a sequence of bytes
Buffered Streams
used to add functionality to other streams and is usually constructed out of other stream objects
random access file
can read/write either sequentially or by accessing single records anywhere in the file
sequential file
typically read or written as an entire file
File
a class used for retrieving properties of files or directories on a disk, does not open files or provide file processing features
Reader, Writer
character stream input and output
InputStream, OutputStream
byte stream input and output
character streams
text files
byte streams
binary files
output stream
flows from a program to an output destination
input stream
flows from an input source into a program usually to be stored in variables
System.err
standard error stream object
System.out
standard output stream object
System.in
standard input stream object
stream
sequence of data flowing from 1 place to another
static nested classes
access to outer class members is limited
java.lang
automatically part of every program
how to embed an image in such a way that it can also be loaded from a jar file
1.) place the image inside the same package as the class
2.) use getResource to look for the image inside jar at runtime
3.) do not use File since the resource is not an external file