import org.apache.commons.vfs.*
fsm = VFS.getManager()
fo = fsm.resolveFile( "ram://test.txt")
// RAM file systemに書き込み
bos = new BufferedOutputStream(fo.getContent().getOutputStream())
bis = new BufferedInputStream(new FileInputStream("test.txt"))
buf = new byte[1024*8]
while((sz = bis.read(buf, 0, 1024*8)) != -1){
bos.write(buf, 0, sz)
}
bos.flush()
bos.close()
// RAM file systemから読み込み
br = new BufferedReader(new InputStreamReader(
fo.getContent().getInputStream()))
while((line = br.readLine()) != null){
println line
}
動作環境
groovy 1.7.1, JDK6 Update19, apache commons vfs 1.0, apache commons logging 1.1.1
0 件のコメント:
コメントを投稿