haskell读写文件相关(含二进制)
生活随笔
收集整理的这篇文章主要介绍了
haskell读写文件相关(含二进制)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
使用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
转载于:https://www.cnblogs.com/zhao1949/p/4838066.html
总结
以上是生活随笔为你收集整理的haskell读写文件相关(含二进制)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Swift初探
- 下一篇: Qt quick 编程