Skip to content

Instantly share code, notes, and snippets.

@pebble8888
Last active December 25, 2020 13:51
Show Gist options
  • Save pebble8888/70bfce115c06c34cb7d4d8e623a71a7e to your computer and use it in GitHub Desktop.
Save pebble8888/70bfce115c06c34cb7d4d8e623a71a7e to your computer and use it in GitHub Desktop.
if let stream:InputStream = InputStream(fileAtPath: "/Users/pebble8888/hoge.txt") {
var buf:[UInt8] = [UInt8](repeating: 0, count: 16)
stream.open()
while true {
let len = stream.read(&buf, maxLength: buf.count)
print("len \(len)")
for i in 0..<len {
print(String(format:"%02x ", buf[i]), terminator: "")
}
if len < buf.count {
break
}
}
stream.close()
}
@stefanos1316
Copy link

Hello,

I 've trying to write the exact same read data to another file but without any success yet.
Would you mind sharing some code for that too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment