Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




Java I/O system

computers


3.9 Java I/O system
3.9.1 Questions:
1. Which of the next statements are true:
a. The File class is used for random access to binary files
b. To list all the file with java extension in a directory, a
FilenameFilter class has to be provided as parameter to the list() method of
the File class
c. A File object can represent both a file and directory
d. Using the File class is possible to look at the characteristics of
files
2. Which is the base class of decorators for classes having as base
class the InputStream?
3. What is the main difference between PrintStream and DataOutputStream
classes?
4. Is it possible to do random access file using InputStream classes?
5. Check the next code snippet for correctness:
// 1. Reading input by lines:
BufferedReader in =
new BufferedReader(
new FileInpuStream("IOStreamDemo.java"));
String s, s2 = new String();
while((s = in.readLine())!= null)
s2 += s + "\n";
in.close );
6. Which class is used to add a new file to a zip archive?
7. How the serialization of a class can be customized in order to avoid
the default serialization?
8. What is the difference in the construction of a Serializable and an
Externalizable object during de serialization?
9. What is weird in the next class:
public class Account implements Externalizable

public void writeExternal(ObjectOutput out)
throws IOException

public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException
}
10. With which kind of objects is working the StreamTokenizer class?



3.9.2 Problems
1. Create a code to open a text file and read the file one line at a
time.
2. Create an externalizable class called Account which contains an id
and a password, the password is not serialized.
3. Write a program that compares the performance of writing the lines
to a file when using buffered and unbuffered I/O both for writer and
output stream classes.
4. Write in a file 4 integers and then reread the third and fourth ones
using random access to the file.
5. Read an arbitrary file, compress it to another file and display the
compression ratio.



Document Info


Accesari: 1249
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )