NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en: http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com.
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂ­tulo en concreto puede realizar una donación directa mediante Paypal:
Questions and Exercises: Basic I/O (The Java™ Tutorials > Essential Classes > Basic I/O)
Trail: Essential Classes
Lesson: Basic I/O
Questions and Exercises
Home Page > Essential Classes > Basic I/O
Questions and Exercises: Basic I/O

Questions

1. What class would you use to read a few pieces of data that are at known positions near the end of a large file?

2. In a format call, what's the best way to indicate a new line?

3. How would you append data to the end of a file? Show the constructor for the class you would use and explain your answer.

Exercises

1. Implement a pair of classes, one Reader and one Writer, that count the number of times a particular character, such as e, is read or written. The character can be specified when the stream is created. Write a program to test your classes. You can use xanadu.txt as the input file.

2. The file datafile begins with a single long that tells you the offset of a single int piece of data within the same file. Using the RandomAccessFile class, write a program that gets the int piece of data. What is the int data?

Check your answers.

Previous page: Summary
Next page: Concurrency