首页 > 代码库 > 读取txt文件

读取txt文件

 UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 100, 320, 200)];
    textView.backgroundColor = [UIColor redColor];
    textView.textAlignment=NSTextAlignmentLeft;
    NSString * str = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"脑筋急转弯" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
    textView.text = str;
    [self.view addSubview:textView];

读取txt文件