cop3252 test #2 files, streams, tools, & inner/nested classes

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

inner classes

have access to outer class members

2
New cards

Scanner (reading from files)

Scanner sc = new Scanner(new File("input.txt"));

3
New cards

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

4
New cards

ObjectInputStream (serialization)

ObjectInputStream in = new ObjectInputStream(new FileInputStream("obj.dat"));

MyClass obj = (MyClass) in.readObject();

5
New cards

ObjectOutputStream (serialization)

ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("obj.dat"));

out.writeObject(myObject);

6
New cards

Formatter (writing formatted text to files)

Formatter fmt = new Formatter("output.txt");

7
New cards

Know how to open an output file and write data to it (write() method)

FileOutputStream fos = new FileOutputStream("output.txt");

fos.write(data);

8
New cards

Know how to open an input file and read data from it (read() method)

FileInputStream fis = new FileInputStream("input.txt");

int data = fis.read();

9
New cards

know what the '.class' file of a nested class looks like

Outer$Inner.class

10
New cards

anonymous inner class

used for one-time class definitions 

11
New cards

-classpath

for specifying the locations of all classes or packages needed (for both javac and java)

12
New cards

-d

for specifying where the result of a javac command will be placed

13
New cards

transient

if an instance variable in an object is declared transient, it will be left out of the serialization 

14
New cards

Serializable

a marker interface, an object can be serialized if its class implements this interface 

15
New cards

serialization of objects

representing an object as a sequence of bytes

16
New cards

Buffered Streams

used to add functionality to other streams and is usually constructed out of other stream objects

17
New cards

random access file

can read/write either sequentially or by accessing single records anywhere in the file

18
New cards

sequential file

typically read or written as an entire file

19
New cards

File

a class used for retrieving properties of files or directories on a disk, does not open files or provide file processing features 

20
New cards

Reader, Writer

character stream input and output

21
New cards

InputStream, OutputStream

byte stream input and output

22
New cards

character streams

text files

23
New cards

byte streams

binary files

24
New cards

output stream

flows from a program to an output destination

25
New cards

input stream

flows from an input source into a program usually to be stored in variables

26
New cards

System.err

standard error stream object

27
New cards

System.out

standard output stream object

28
New cards

System.in

standard input stream object

29
New cards

stream

sequence of data flowing from 1 place to another

30
New cards

static nested classes

access to outer class members is limited

31
New cards

java.lang

automatically part of every program

32
New cards

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