| Page 14 of 38 Prev | Index | Next |
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.FileNotFoundException;
public class ExReadFile {
public static void main(String[] args) {
FileReader r = null;
File f = new File("jython-presentation.py");
try {
r = new FileReader(f);
} catch (FileNotFoundException e) {
return;
}
LineNumberReader lnr = new LineNumberReader(r);
String line = null;
do {
try {
line = lnr.readLine();
} catch (IOException e) {
line = null;
}
if (line != null) {
System.out.println(line);
}
} while(line != null);
try {
r.close();
} catch (IOException e) {}
}
}
fp = open("jython-presentation.py")
try:
for line in fp:
print line,
finally:
fp.close()
| Page 14 of 38 Prev | Index | Next |