Add a method to the class WebPageWriter that will print out the file names for all files ending with “.wav” in a passed directory. You can add a link to the sound files name which will play the sound when the user clicks on the link. Just use the link (anchor) tag: soundFile.wav.
What will be an ideal response?
```
/? ?
? Method t o c r e a t e a page w i t h l i n k s t o t h e sound f i l e s
? in the passed d i r e c t o r y
? @param d i r e c t o r y t h e d i r e c t o r y t o c r e a t e t h e page f o r
?/
public void createSoundPage ( S t r i n g d i r e c t o r y )
{
S t r i n g name = null ;
S t r i n g body = ” ” ;
S t r i n g endOfLine = System . g e t P r o p e r t y ( ” l i n e . s e p a r a t o r ” ) ;
// t r y t h e f o l l o w i n g
try {
// c r e a t e t h e F i l e o b j e c t
F i l e d i r = new F i l e ( d i r e c t o r y ) ;
// g e t t h e f u l l p a t h name o f t h e d i r e c t o r y
S t r i n g pathName = d i r e c t o r y + d i r . getName ( ) + ”S . html ” ;
BufferedWriter writer =
new B u f f e r e d W r i t e r (new F i l e W r i t e r ( pathName ) ) ;
// w r i t e t h e s t a r t
writeStart ( writer );
// w r i t e t h e head
writeHead ( w r i t e r , ” Sounds from ” + d i r e c t o r y ) ;
// g e t t h e a r r a y o f i t e m s i n t h e d i r e c t o r y
String [ ] items = d i r . l i s t ( ) ;
// l o o p t h r o u g h t h e rows
f o r ( i nt i = 0 ; i < i t e m s . l e n g t h ; i ++)
{
name = i t e m s [ i ] ;
i f ( name . indexOf ( ” . wav” ) >= 0 )
{
body = body + ”
endOfLine ;
}
}
// w r i t e t h e body
writeBody ( w r i t e r , body ) ;
// w r i t e t h e end
writeEnd ( w r i t e r ) ;
// c l o s e t h e w r i t e r
writer . close ( ) ;
} catch ( E x c e p t i o n ex ) {
ex . p r i n t S t a c k T r a c e ( ) ;
}
}
```
You might also like to view...
A ______ determines the capability of the mobile device, such as screen resolution, and directs browsers to CSS.
a. sprite b. viewport c. media query d. fragment identifier
To ________ data means to consolidate or summarize data, and can be accomplished through functions such as SUM and AVERAGE
Fill in the blank(s) with correct word
When connecting two devices for data on a vertical cross connect, which of the following cables would be used to connect those devices?
A. CAT5e B. Fiber C. Coaxial D. CAT6
The ends of a(n) ____________________ path do not connect.
Fill in the blank(s) with the appropriate word(s).