Documentation

The Java™ Tutorials
Hide TOC
Questions and Exercises问题和练习
Trail: Essential Java Classes
Lesson: Basic I/O

Questions and Exercises: Basic I/O问题和练习:基本输入输出

Questions问题

1. What class and method would you use to read a few pieces of data that are at known positions near the end of a large file?您将使用什么类和方法来读取位于大文件末尾附近的已知位置的几段数据?

2. When invoking format, what is the best way to indicate a new line?调用format时,指示新行的最佳方式是什么?

3. How would you determine the MIME type of a file?如何确定文件的MIME类型?

4. What method(s) would you use to determine whether a file is a symbolic link?您将使用什么方法来确定文件是否为符号链接?

Exercises练习

1. Write an example that counts the number of times a particular character, such as e, appears in a file. The character can be specified at the command line. 编写一个示例,计算特定字符(如e)在文件中出现的次数。可以在命令行中指定该字符。You can use xanadu.txt as the input file.您可以使用xanadu.txt作为输入文件。

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. 文件datafile以一个long开头,告诉您同一文件中单个int数据段的偏移量。Write a program that gets the int piece of data. 编写一个获取int数据段的程序。What is the int data?什么是int数据?

Check your answers.检查你的答案。


Previous page: Summary
Next page: Concurrency