打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
REBOL 3 Functions: read

REBOL 3 Functions: read

read  source  /part  length  /seek  index  /string  /lines

Read from a file, URL, or other port.

Arguments:

source [port! file! url! block!]

Refinements:

/part - Partial read a given number of units (source relative)

length [number!]

/seek - Read from a specific position (source relative)

index [number!]

/string - Convert UTF and line terminators to standard text string

/lines - Convert to block of strings (implies /string)

See also:

write   open   close   load   save  

Description

Using READ is the simplest way to get information from a file or URL. This is a higher level port operation that opens a port, reads some or all of the data, then closes the port and returns the data that was read. When used on a file, or URL, the contents of the file, or URL are returned as a string.

The /LINES refinement returns read content as a series of lines. One line is created for each line terminator found in the read data.

The /PART refinement reads the specified number of elements from the file, URL, or port. Reading a file or URL will read the specified number of characters. Used with /LINES, it reads a specified number of lines.

See the User's Guide for more detailed explanation of using READ and its refinements.

write %rebol-test-file.r "text file"

print read %rebol-test-file.r

read

write %rebol-test-file.r [

{A learned blockhead is a greater man

than an ignorant blockhead.

    -- Rooseveldt Franklin}

]

probe first read/lines %rebol-test-file.r

write

probe pick (read/lines %rebol-test-file.r) 3

probe read/part %rebol-test-file.r 9

probe read/with %rebol-test-file.r "blockhead"

write/append %matrix.avi to-binary "abcdefg"

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Java in a Nutshell, 4th Edition(2/3)
Python | 对比文件内容差异
android download image to sd card
lua 读写文件
不同配置文件的初始化Hibernate心得
FileUtils方法大全
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服