Saturday, 12 July 2008

Java/Jython to read file

All the programs is quite preliminary and in Jython environment.

1. BufferedReader + FileReader
====================
import java.io as ji
fr=ji.FileReader('a.txt')
br=ji.BufferedReader(fr)
text=br.readLine()

2. FileInputStream + BufferedInputStream + DataInputStream
====================
import java.io as ji
fis=ji.FileInputStream('a.txt')
bis=ji.BufferedInputStream(fis)
dis=ji.DataInputStream(bis)
text=dis.readLine()

3. FileInputStream + BufferedInputStream + InputStreamReader + BufferedReader
====================
import java.io as ji
fis=ji.FileInputStream('a.txt')
bis=ji.BufferedInputStream(fis)
isr=ji.InputStreamReader(bis)
br=ji.BufferedReader(isr)
text=br.readLine()

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter