Reference for Processing version 1.5. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.
| Name | loadBytes() | ||
|---|---|---|---|
| Examples | // 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(); | ||
| 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. The filename parameter can also be a URL to a file found online. For security reasons, a Processing sketch found online can only download files from the same server from which it came. Getting around this restriction requires a signed applet. | ||
| Syntax | loadBytes(filename); | ||
| Parameters | 
 | ||
| Returns | byte[] | ||
| Usage | Web & Application | ||
| Related | loadStrings() saveStrings() saveBytes() | 

