|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectdemo.LueUsers2
public class LueUsers2
Luetaan tiedosto ja tulostetaan sen muokattuna näytölle.
Seuraavassa html sulut korvattu ( )-merkeillä
(!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN")
(html)
(head)
(base target=m1)
...
93 (a href="vesal/index.html?r=1")Vesa Lappalainen(/a) = 8.5(br)
94 (a href="mattim/index.html?r=1")Matti Meikäläinen(/a) = 8(br)
95 (a href="teppot/index.html?r=1")Teppo Teikäläinen(/a) = 9(br)
...
ja tulostaa sen muodossa:
93 Vesa Lappalainen = 8.5 - vesal
94 Matti Meikäläinen = 8 - mattim
95 Teppo Teikäläinen = 9 - teppot
eli riisuu pois kaikki rivit, joissa ei ole linkkiä ja linkkiriveistä
tulostetaan em. tiedot em. muodossa
#THROWS IOException
#STATICIMPORT
#import java.io.*;
#import fi.jyu.mit.ohj2.*;
String sisalto =
"(!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\")\n"+
"(html)\n"+
"(head)\n"+
"(base target=m1)\n"+
"(title)demo3(/title)\n"+
"(/head)\n"+
"(body)\n"+
"(h1)demo3(/h1)\n"+
"93 (a href=\"vesal/index.html?r=1\")Vesa Lappalainen(/a) = 8.5(br)\n"+
"94 (a href=\"mattim/index.html?r=1\")Matti Meikäläinen(/a) = 8(br)\n"+
"95 (a href=\"teppot/index.html?r=1\")Teppo Teikäläinen(/a) = 9(br)\n"+
"(/body)\n"+
"(/html>\n";
sisalto = sisalto.replace('(','<').replace(')','>');
VertaaTiedosto.kirjoitaTiedosto("users.test",sisalto);
Suuntaaja.StringOutput so = new Suuntaaja.StringOutput();
main(new String[]{"users.test"});
String tulos = "93 Vesa Lappalainen = 8.5 - vesal\n"+
"94 Matti Meikäläinen = 8.0 - mattim\n"+
"95 Teppo Teikäläinen = 9.0 - teppot\n";
so.ero(tulos) === null;
so.palauta();
VertaaTiedosto.tuhoaTiedosto("users.test");
| Constructor Summary | |
|---|---|
LueUsers2()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
Testataan LueUsers2-luokkaa |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LueUsers2()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
throws java.io.IOException
args - luettavan tiedoston nimi. Jos ei ole, kysytään käyttäjältä
java.io.IOException - jos tiedostojen kanssa ongelmia
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||