Jump to content

Delete a file: Difference between revisions

Added support for J language
m (→‎{{header|PowerShell}}: forgot to delete the directory)
(Added support for J language)
Line 175:
RootDir fileNamed("input.txt") remove
RootDir directoryNamed("docs") remove</lang>
 
=={{header|J}}==
The J standard library comes with a set of file access utilities.
<lang j> load 'files'
ferase 'input.txt'
ferase '\input.txt'
ferase 'docs'
ferase '\docs'
</lang>
 
The function above actually uses a foreign conjunction and defined in the 'files' library like so:
<lang j>NB. =========================================================
NB.*ferase v erases a file
NB. Returns 1 if successful, otherwise _1
ferase=: (1!:55 :: _1:) @ (fboxname &>) @ boxopen
</lang>
 
This means that you can directly erase files and directories without loading the 'files' library.
<lang j> 1!:55 <'input.txt'
1!:55 <'\input.txt'
1!:55 <'docs'
1!:55 <'\docs'
</lang>
 
=={{header|Java}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.