mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
69 lines
1.2 KiB
XML
69 lines
1.2 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>loadBytes()</name>
|
|
|
|
<category>Input/Output</category>
|
|
|
|
<subcategory>Files</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image></image>
|
|
<code>
|
|
// open a file and read its binary data
|
|
byte b[] = loadBytes("something.dat");
|
|
|
|
// print each value, from 0 to 255
|
|
for (int i = 0; i < b.length; i++) {
|
|
// every tenth number, start a new line
|
|
if ((i % 10) == 0) {
|
|
println();
|
|
}
|
|
|
|
// bytes are from -128 to 127, this converts to 0 to 255
|
|
int a = b[i] & 0xff;
|
|
print(a + " ");
|
|
}
|
|
// print a blank line at the end
|
|
println();
|
|
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
Reads the contents of a file or url and places it in a byte array. If a file is specified, it must be located in the sketch's "data" directory/folder.
|
|
</description>
|
|
|
|
<syntax>
|
|
loadBytes(<c>filename</c>);
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>filename</label>
|
|
<description>String: name of a file in the data folder or a url.</description>
|
|
</parameter>
|
|
|
|
<returns>byte[]</returns>
|
|
|
|
<related>
|
|
loadStrings()
|
|
saveStrings()
|
|
saveBytes()
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Function</type>
|
|
|
|
<partof>Core</partof>
|
|
|
|
|
|
<level>Extended</level>
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|