首页 > 其他 > 详细

haskell读写文件相关(含二进制)

时间:2015-09-25 14:29:35      阅读:165      评论:0      收藏:0      [点我收藏+]


使用System.IO模块

使用函数

openBinaryFile :: FilePath -> IOMode -> IO Handle

打开文件 IOMode为 ReadWriteMode, 不然会截断文件

eg:

h <- openFile "b.txt" ReadWriteMode
hPutChar h ‘b‘
hPutChar h ‘b‘
hPutChar h ‘b‘
hPutChar h ‘b‘
hPutChar h ‘b‘
hClose h

如果处理二进制文件

要引入模块Data.ByteString

hPut :: Handle -> ByteString -> IO ()

Outputs a ByteString to the specified Handle.

===========================

库文档路径

https://downloads.haskell.org/~ghc/7.6-latest/docs/html/libraries/index.html

 

haskell读写文件相关(含二进制)

原文:http://www.cnblogs.com/zhao1949/p/4838066.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!