Java 7 for Absolute Beginners
CHAPTER 7 ■ WRITING A USER INTERFACE the game is over (because the player won or lost) or the game should continue. If the user ...
CHAPTER 7 ■ WRITING A USER INTERFACE if (e.getActionCommand().equals("Medium (16 x 16, 40 mines)")) { int previousRows = mineSwe ...
CHAPTER 7 ■ WRITING A USER INTERFACE Figure 7-5. A finished MineSweeper game Summary In this chapter, you saw a number of Swing ...
CHAPTER 7 ■ WRITING A USER INTERFACE The normal idiom for working with Swing components is to create a component, set whatever ...
C H A P T E R 8 151 Writing and Reading Files Writing data to and reading data from files are common tasks for almost any kind o ...
CHAPTER 8 ■ WRITING AND READING FILES Figure 8-1. A test directory Listing 8-1. Creating an empty file package com.apress.java7f ...
CHAPTER 8 ■ WRITING AND READING FILES characters, but we can't count on such things. Instead, we should specify a file name by u ...
CHAPTER 8 ■ WRITING AND READING FILES Listing 8-3. Getting a File object for an existing file package com.apress.java7forabsolut ...
CHAPTER 8 ■ WRITING AND READING FILES You don't need to check for the file after you delete it, by the way. If the operation fai ...
CHAPTER 8 ■ WRITING AND READING FILES String tempDirectoryName = "C:" + File.separator + "test"; File tempDirectory = new File(t ...
CHAPTER 8 ■ WRITING AND READING FILES Some systems create files and leave them on the system for a long time (usually until a us ...
CHAPTER 8 ■ WRITING AND READING FILES Listing 8-8. Creating a directory package com.apress.java7forabsolutebeginners.examples; i ...
CHAPTER 8 ■ WRITING AND READING FILES System.out.println("Created a directory called " + testDirectoryName); } } Notice the Syst ...
CHAPTER 8 ■ WRITING AND READING FILES Deleting Multiple Directories If you use the mkdirs method and the JVM can't create the fi ...
CHAPTER 8 ■ WRITING AND READING FILES for (int pathCounter = 0; pathCounter < pathParts.length; pathCounter++) { currentPath ...
CHAPTER 8 ■ WRITING AND READING FILES Reading a File's Content Before we can get much further, we first need a file that contain ...
CHAPTER 8 ■ WRITING AND READING FILES } catch (IOException ioe) { System.out.println("Couldn't read from a file called " + fileN ...
CHAPTER 8 ■ WRITING AND READING FILES public static void main(String[] args) { // Specify the file String fileName = "C:" + File ...
CHAPTER 8 ■ WRITING AND READING FILES Before we proceed with reviewing the file, let's examine the reverseByteArray method. It d ...
CHAPTER 8 ■ WRITING AND READING FILES between the original and the reversed content. Listing 8-17 shows the code with the additi ...
«
4
5
6
7
8
9
10
11
12
13
»
Free download pdf