Sealyu

--- 博客已迁移至: http://www.sealyu.com/blog

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  618 随笔 :: 87 文章 :: 225 评论 :: 0 Trackbacks
NSFileManager can:
Create a new file
Read from an exiting file
Write data to file
Rename a file
Remove (delete a file)
Test for the existence of a file
Determine the size of a file as well as other attributes
Make a copy of a file
Test two files to see whether their contents are equal

这些操作都可以被在directories下执行。例如你创建一个目录,读出其中元素或者删除。另一个特色是link files。也就是,一个相同的文件存在在两个不同的名字下,或许甚至是不同的目录下。

为了打开一个文件并执行多次读写操作,你用NSFileHandle提供的方法。主要:
Open a file or reading, writing , or updating (reading and writing)
Seek to a specified position within a file
Read or write a specified number of bytes from and to a file.
这个类提供的方法也可以被应用在Device 或者 socket上。

管理文件和目录:NSFileManager
       一个文件或者目录被通过pathname 唯一的定义给NSFileManager。 一个pathname就是一个NSString类型对象能被相关联或者是全部的pathname。
一 个相关联的pathname是关联到当前目录的那个pathname 。 所以文件名字copy1.m 将意味着这个文件在当前的目录。“/”(Slash) 实际上是根目录。/users/somone 是一个pathname 指定3个目录 / 根目录,users目录和someone目录。
~被用来缩写一个用户的主目录比如~linda = /users / linda。 在UNIX类型的pathname里面 “ ." 就是当前目录". . "就是父目录(上一级)


NSData:
用这个类来处理文件的时候,你常常需要读出一个临时区域中的变量,通常叫做buffer(缓冲区)。NSData类提供一个简单的方式建立缓冲区,读出里面文件的内容,或者写一个buffer中的内容到一个文件。
你可以定义可变的或者不可变的存储空间。

posted on 2010-11-12 21:32 seal 阅读(514) 评论(0)  编辑  收藏 所属分类: iPhone

只有注册用户登录后才能发表评论。


网站导航: