Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create a file filled with random bytes for testing
ResourceFunction["CreateRandomFile"]["n"] creates a random file of n bytes in the default area for temporary files on your computer system. | |
ResourceFunction["CreateRandomFile"][path,n] creates a random file at the location specified by path. |
"file" | a string corresponding to a local file path |
File["file"] | a local file path |
LocalObject[…] | a LocalObject |
CloudObject[…] | a CloudObject |
Create a file containing 50 random bytes:
In[1]:= |
Out[1]= |
Create a random file at a specified path:
In[2]:= |
Out[2]= |
Verify the file size:
In[3]:= |
Out[3]= |
View the contents:
In[4]:= |
Out[4]= |
Clean up:
In[5]:= |
Specify a path using a File object:
In[6]:= |
Out[6]= |
In[7]:= |
Create a random LocalObject:
In[8]:= |
Out[8]= |
In[9]:= |
Create a random CloudObject:
In[10]:= |
Out[10]= |
In[11]:= |
Create a random CloudObject at a specific location:
In[12]:= |
Out[12]= |
In[13]:= |
Specify Permissions:
In[14]:= |
Out[14]= |
In[15]:= |
By default, the parent directory will be created for the file if it does not already exist:
In[16]:= |
Out[16]= |
In[17]:= |
Out[17]= |
Do not create a file if the parent directory does not exist:
In[18]:= |
Out[18]= |
In[19]:= |
Out[19]= |
By default, CreateRandomFile will not overwrite existing files:
In[20]:= |
Out[20]= |
In[21]:= |
Out[21]= |
Overwrite the target file if it already exists:
In[22]:= |
Out[22]= |
In[23]:= |
In[24]:= |
Create a file for testing performance of different file hashing methods:
In[25]:= |
Out[25]= |
In[26]:= |
Out[26]= |
In[27]:= |
Out[27]= |
Create a cloud object with random data for testing download speeds:
In[28]:= |
Out[28]= |
In[29]:= |
Out[29]= |
In[30]:= |
CreateRandomFile writes data in batches so memory usage will not exceed what is available:
In[31]:= |
Out[31]= |
In[32]:= |
Out[32]= |
In[33]:= |
Specifying zero bytes is effectively equivalent to using CreateFile:
In[34]:= |
Out[34]= |
In[35]:= |
Out[35]= |
This work is licensed under a Creative Commons Attribution 4.0 International License