langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
27
Task/File-IO/NetRexx/file-io.netrexx
Normal file
27
Task/File-IO/NetRexx/file-io.netrexx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
import java.nio.
|
||||
|
||||
parse arg infileName outfileName .
|
||||
|
||||
if infileName = '' | infileName.length = 0 then infileName = 'data/input.txt'
|
||||
if outfileName = '' | outfileName.length = 0 then outfileName = 'data/output.txt'
|
||||
|
||||
binaryCopy(infileName, outfileName)
|
||||
|
||||
return
|
||||
|
||||
method binaryCopy(infileName, outfileName) public static
|
||||
|
||||
do
|
||||
infile = Paths.get('.', [String infileName])
|
||||
outfile = Paths.get('.', [String outfileName])
|
||||
fileOctets = Files.readAllBytes(infile)
|
||||
Files.write(outfile, fileOctets, [StandardOpenOption.WRITE, StandardOpenOption.CREATE])
|
||||
|
||||
catch ioex = IOException
|
||||
ioex.printStackTrace()
|
||||
end
|
||||
|
||||
return
|
||||
13
Task/File-IO/OCaml/file-io-1.ocaml
Normal file
13
Task/File-IO/OCaml/file-io-1.ocaml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
let () =
|
||||
let ic = open_in "input.txt" in
|
||||
let oc = open_out "output.txt" in
|
||||
try
|
||||
while true do
|
||||
let s = input_line ic in
|
||||
output_string oc s;
|
||||
output_char oc '\n';
|
||||
done
|
||||
with End_of_file ->
|
||||
close_in ic;
|
||||
close_out oc;
|
||||
;;
|
||||
12
Task/File-IO/OCaml/file-io-2.ocaml
Normal file
12
Task/File-IO/OCaml/file-io-2.ocaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
let () =
|
||||
let ic = open_in "input.txt" in
|
||||
let oc = open_out "output.txt" in
|
||||
try
|
||||
while true do
|
||||
let c = input_char ic in
|
||||
output_char oc c
|
||||
done
|
||||
with End_of_file ->
|
||||
close_in ic;
|
||||
close_out oc;
|
||||
;;
|
||||
20
Task/File-IO/Objeck/file-io.objeck
Normal file
20
Task/File-IO/Objeck/file-io.objeck
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use IO;
|
||||
|
||||
bundle Default {
|
||||
class Test {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
len := File->Size("input.txt");
|
||||
buffer := Byte->New[len];
|
||||
in := FileReader->New("input.txt");
|
||||
if(in->IsOpen() <> Nil) {
|
||||
in->ReadBuffer(0, len, buffer);
|
||||
out := FileWriter->New("output.txt");
|
||||
if(out->IsOpen() <> Nil) {
|
||||
out->WriteBuffer(0, len, buffer);
|
||||
out->Close();
|
||||
};
|
||||
in->Close();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Task/File-IO/Object-Pascal/file-io.object
Normal file
10
Task/File-IO/Object-Pascal/file-io.object
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
uses
|
||||
classes;
|
||||
begin
|
||||
with TFileStream.Create('input.txt', fmOpenRead) do
|
||||
try
|
||||
SaveToFile('output.txt');
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
3
Task/File-IO/Objective-C/file-io.m
Normal file
3
Task/File-IO/Objective-C/file-io.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
NSData *data = [NSData dataWithContentsOfFile:@"input.txt"];
|
||||
|
||||
[data writeToFile:@"output.txt" atomically:YES];
|
||||
1
Task/File-IO/OpenEdge-Progress/file-io.openedge
Normal file
1
Task/File-IO/OpenEdge-Progress/file-io.openedge
Normal file
|
|
@ -0,0 +1 @@
|
|||
COPY-LOB FROM FILE "input.txt" TO FILE "output.txt".
|
||||
17
Task/File-IO/Oz/file-io.oz
Normal file
17
Task/File-IO/Oz/file-io.oz
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
declare
|
||||
class TextFile from Open.file Open.text end
|
||||
|
||||
In = {New TextFile init(name:"input.txt")}
|
||||
Out = {New TextFile init(name:"output.txt" flags:[write text create truncate])}
|
||||
|
||||
proc {CopyAll In Out}
|
||||
case {In getS($)} of false then skip
|
||||
[] Line then
|
||||
{Out putS(Line)}
|
||||
{CopyAll In Out}
|
||||
end
|
||||
end
|
||||
in
|
||||
{CopyAll In Out}
|
||||
{Out close}
|
||||
{In close}
|
||||
2
Task/File-IO/PARI-GP/file-io.pari
Normal file
2
Task/File-IO/PARI-GP/file-io.pari
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
f=read("filename.in");
|
||||
write("filename.out", f);
|
||||
8
Task/File-IO/PL-I/file-io.pli
Normal file
8
Task/File-IO/PL-I/file-io.pli
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
declare in file, out file;
|
||||
|
||||
open file (in) title ('/INPUT.TXT,type(text),recsize(100)') input;
|
||||
open file (out) title ('/OUTPUT.TXT,type(text),recsize(100) output;
|
||||
do forever;
|
||||
get file (in) edit (line) (L);
|
||||
put file (out) edit (line) (A);
|
||||
end;
|
||||
5
Task/File-IO/Perl-6/file-io-1.pl6
Normal file
5
Task/File-IO/Perl-6/file-io-1.pl6
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
my $in = open "input.txt";
|
||||
my $out = open "output.txt", :w;
|
||||
for $in.lines -> $line {
|
||||
$out.say($line);
|
||||
}
|
||||
1
Task/File-IO/Perl-6/file-io-2.pl6
Normal file
1
Task/File-IO/Perl-6/file-io-2.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
(open "output.txt", :w).print(slurp "input.txt")
|
||||
6
Task/File-IO/Pop11/file-io-1.pop11
Normal file
6
Task/File-IO/Pop11/file-io-1.pop11
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
lvars i_stream = discin('input.txt');
|
||||
lvars o_stream = discout('output.txt');
|
||||
lvars c;
|
||||
while (i_stream() ->> c) /= termin do
|
||||
o_stream(c);
|
||||
endwhile;
|
||||
7
Task/File-IO/Pop11/file-io-2.pop11
Normal file
7
Task/File-IO/Pop11/file-io-2.pop11
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
lvars i_file = sysopen('input.txt', 0, true);
|
||||
lvars o_file = syscreate('output.txt', 1, true);
|
||||
lvars buff = inits(4096);
|
||||
lvars i;
|
||||
while (sysread(i_file, buff, length(buff)) ->> i) > 0 do
|
||||
syswrite(o_file, buff, i);
|
||||
endwhile;
|
||||
1
Task/File-IO/PowerShell/file-io-1.psh
Normal file
1
Task/File-IO/PowerShell/file-io-1.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
Get-Content $PWD\input.txt | Out-File $PWD\output.txt
|
||||
1
Task/File-IO/PowerShell/file-io-2.psh
Normal file
1
Task/File-IO/PowerShell/file-io-2.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
Get-Content $PWD\input.txt | Set-Content $PWD\output.txt
|
||||
1
Task/File-IO/PureBasic/file-io-1.purebasic
Normal file
1
Task/File-IO/PureBasic/file-io-1.purebasic
Normal file
|
|
@ -0,0 +1 @@
|
|||
CopyFile("input.txt","output.txt")
|
||||
13
Task/File-IO/PureBasic/file-io-2.purebasic
Normal file
13
Task/File-IO/PureBasic/file-io-2.purebasic
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
in = ReadFile(#PB_Any,"input.txt")
|
||||
If in
|
||||
out = CreateFile(#PB_Any,"output.txt")
|
||||
If out
|
||||
Define MyLine$
|
||||
While Not Eof(in)
|
||||
MyLine$ = ReadString(in)
|
||||
WriteString(out,MyLine$)
|
||||
Wend
|
||||
CloseFile(out)
|
||||
EndIf
|
||||
CloseFile(in)
|
||||
EndIf
|
||||
14
Task/File-IO/PureBasic/file-io-3.purebasic
Normal file
14
Task/File-IO/PureBasic/file-io-3.purebasic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
If ReadFile(0,"input.txt")
|
||||
Define MyLine$, *Buffer, length
|
||||
length=FileSize("input.txt")
|
||||
*Buffer = AllocateMemory(length)
|
||||
If *Buffer
|
||||
If OpenFile(1,"output.txt")
|
||||
ReadData(0, *Buffer, length)
|
||||
WriteData(1, *Buffer, length)
|
||||
CloseFile(1)
|
||||
EndIf
|
||||
FreeMemory(*Buffer)
|
||||
EndIf
|
||||
CloseFile(0)
|
||||
EndIf
|
||||
11
Task/File-IO/REALbasic/file-io.realbasic
Normal file
11
Task/File-IO/REALbasic/file-io.realbasic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Sub WriteToFile(input As FolderItem, output As FolderItem)
|
||||
Dim tis As TextInputStream
|
||||
Dim tos As TextOutputStream
|
||||
tis = tis.Open(input)
|
||||
tos = tos.Create(output)
|
||||
While Not tis.EOF
|
||||
tos.WriteLine(tis.ReadLine)
|
||||
Wend
|
||||
tis.Close
|
||||
tos.Close
|
||||
End Sub
|
||||
7
Task/File-IO/REBOL/file-io.rebol
Normal file
7
Task/File-IO/REBOL/file-io.rebol
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
write %output.txt read %input.txt
|
||||
|
||||
; No line translations:
|
||||
write/binary %output.txt read/binary %input.txt
|
||||
|
||||
; Save a web page:
|
||||
write/binary %output.html read http://rosettacode.org
|
||||
15
Task/File-IO/RapidQ/file-io-1.rapidq
Normal file
15
Task/File-IO/RapidQ/file-io-1.rapidq
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
$INCLUDE "rapidq.inc"
|
||||
|
||||
DIM File1 AS QFileStream
|
||||
DIM File2 AS QFileStream
|
||||
|
||||
File1.Open("input.txt", fmOpenRead)
|
||||
File2.Open("output.txt", fmCreate)
|
||||
|
||||
WHILE NOT File1.EOF
|
||||
data$ = File1.ReadLine
|
||||
File2.WriteLine(data$)
|
||||
WEND
|
||||
|
||||
File1.Close
|
||||
File2.Close
|
||||
12
Task/File-IO/RapidQ/file-io-2.rapidq
Normal file
12
Task/File-IO/RapidQ/file-io-2.rapidq
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
$INCLUDE "rapidq.inc"
|
||||
|
||||
DIM File1 AS QFileStream
|
||||
DIM File2 AS QFileStream
|
||||
|
||||
File1.Open("input.txt", fmOpenRead)
|
||||
File2.Open("output.txt", fmCreate)
|
||||
|
||||
File2.CopyFrom(File1, 0)
|
||||
|
||||
File1.Close
|
||||
File2.Close
|
||||
1
Task/File-IO/Raven/file-io.raven
Normal file
1
Task/File-IO/Raven/file-io.raven
Normal file
|
|
@ -0,0 +1 @@
|
|||
'input.txt' read 'output.txt' write
|
||||
2
Task/File-IO/Retro/file-io.retro
Normal file
2
Task/File-IO/Retro/file-io.retro
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
with files'
|
||||
here dup "input.txt" slurp "output.txt" spew
|
||||
18
Task/File-IO/Run-BASIC/file-io.run
Normal file
18
Task/File-IO/Run-BASIC/file-io.run
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
open "input.txt" for input as #in
|
||||
fileLen = LOF(#in) 'Length Of File
|
||||
fileData$ = input$(#in, fileLen) 'read entire file
|
||||
close #in
|
||||
|
||||
open "output.txt" for output as #out
|
||||
print #out, fileData$ 'write entire fie
|
||||
close #out
|
||||
end
|
||||
|
||||
' or directly with no intermediate fileData$
|
||||
|
||||
open "input.txt" for input as #in
|
||||
open "output.txt" for output as #out
|
||||
fileLen = LOF(#in) 'Length Of File
|
||||
print #out, input$(#in, fileLen) 'entire file
|
||||
close #in
|
||||
close #out
|
||||
4
Task/File-IO/SNOBOL4/file-io.sno
Normal file
4
Task/File-IO/SNOBOL4/file-io.sno
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
input(.input,5,,'input.txt')
|
||||
output(.output,6,,'output.txt')
|
||||
while output = input :s(while)
|
||||
end
|
||||
7
Task/File-IO/Seed7/file-io.seed7
Normal file
7
Task/File-IO/Seed7/file-io.seed7
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "osfiles.s7i";
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
copyFile("input.txt", "output.txt");
|
||||
end func;
|
||||
3
Task/File-IO/Slate/file-io.slate
Normal file
3
Task/File-IO/Slate/file-io.slate
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(File newNamed: 'input.txt' &mode: File Read) sessionDo: [| :in |
|
||||
(File newNamed: 'output.txt' &mode: File CreateWrite) sessionDo: [| :out |
|
||||
in >> out]]
|
||||
10
Task/File-IO/Standard-ML/file-io.ml
Normal file
10
Task/File-IO/Standard-ML/file-io.ml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fun copyFile (from, to) =
|
||||
let
|
||||
val instream = TextIO.openIn from
|
||||
val outstream = TextIO.openOut to
|
||||
val () = TextIO.output (outstream, TextIO.inputAll instream)
|
||||
val () = TextIO.closeIn instream
|
||||
val () = TextIO.closeOut outstream
|
||||
in
|
||||
true
|
||||
end handle _ => false;
|
||||
22
Task/File-IO/Toka/file-io-1.toka
Normal file
22
Task/File-IO/Toka/file-io-1.toka
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
( source dest -- )
|
||||
{
|
||||
value| source dest size buffer |
|
||||
{
|
||||
{
|
||||
[ "W" file.open to dest ] is open-dest
|
||||
[ "R" file.open to source ] is open-source
|
||||
[ open-dest open-source ]
|
||||
} is open-files
|
||||
{
|
||||
[ source file.size to size ] is obtain-size
|
||||
[ size malloc to buffer ] is allocate-buffer
|
||||
[ obtain-size allocate-buffer ]
|
||||
} is create-buffer
|
||||
[ source dest and 0 <> ] is check
|
||||
[ open-files create-buffer check ]
|
||||
} is prepare
|
||||
[ source buffer size file.read drop ] is read-source
|
||||
[ dest buffer size file.write drop ] is write-dest
|
||||
[ source file.close dest file.close ] is close-files
|
||||
[ prepare [ read-source write-dest close-files ] ifTrue ]
|
||||
} is copy-file
|
||||
4
Task/File-IO/Toka/file-io-2.toka
Normal file
4
Task/File-IO/Toka/file-io-2.toka
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[ ( source dest -- )
|
||||
swap file.slurp dup 0 <>
|
||||
[ >r "W" file.open dup r> string.getLength file.write drop file.close ] ifTrue
|
||||
] is copy-file
|
||||
1
Task/File-IO/Toka/file-io-3.toka
Normal file
1
Task/File-IO/Toka/file-io-3.toka
Normal file
|
|
@ -0,0 +1 @@
|
|||
" input.txt" " output.txt" copy-file
|
||||
4
Task/File-IO/UNIX-Shell/file-io-1.sh
Normal file
4
Task/File-IO/UNIX-Shell/file-io-1.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
while IFS= read -r a; do
|
||||
printf '%s\n' "$a"
|
||||
done <input.txt >output.txt
|
||||
2
Task/File-IO/UNIX-Shell/file-io-2.sh
Normal file
2
Task/File-IO/UNIX-Shell/file-io-2.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
cat input.txt >output.txt
|
||||
2
Task/File-IO/UNIX-Shell/file-io-3.sh
Normal file
2
Task/File-IO/UNIX-Shell/file-io-3.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
cp input.txt output.txt
|
||||
5
Task/File-IO/Ursala/file-io.ursala
Normal file
5
Task/File-IO/Ursala/file-io.ursala
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#import std
|
||||
|
||||
#executable ('parameterized','')
|
||||
|
||||
fileio = ~command.files; &h.path.&h:= 'output.txt'!
|
||||
1
Task/File-IO/VBScript/file-io.vbscript
Normal file
1
Task/File-IO/VBScript/file-io.vbscript
Normal file
|
|
@ -0,0 +1 @@
|
|||
CreateObject("Scripting.FileSystemObject").OpenTextFile("output.txt",2,-2).Write CreateObject("Scripting.FileSystemObject").OpenTextFile("input.txt", 1, -2).ReadAll
|
||||
3
Task/File-IO/Vedit-macro-language/file-io.vedit
Normal file
3
Task/File-IO/Vedit-macro-language/file-io.vedit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
File_Open("input.txt")
|
||||
File_Save_As("output.txt", NOMSG)
|
||||
Buf_Close(NOMSG)
|
||||
17
Task/File-IO/Visual-Basic-.NET/file-io.visual
Normal file
17
Task/File-IO/Visual-Basic-.NET/file-io.visual
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'byte copy
|
||||
My.Computer.FileSystem.WriteAllBytes("output.txt", _
|
||||
My.Computer.FileSystem.ReadAllBytes("input.txt"), False)
|
||||
|
||||
'text copy
|
||||
Using input = IO.File.OpenText("input.txt"), _
|
||||
output As New IO.StreamWriter(IO.File.OpenWrite("output.txt"))
|
||||
output.Write(input.ReadToEnd)
|
||||
End Using
|
||||
|
||||
'Line by line text copy
|
||||
Using input = IO.File.OpenText("input.txt"), _
|
||||
output As New IO.StreamWriter(IO.File.OpenWrite("output.txt"))
|
||||
Do Until input.EndOfStream
|
||||
output.WriteLine(input.ReadLine)
|
||||
Loop
|
||||
End Using
|
||||
15
Task/File-IO/XPL0/file-io.xpl0
Normal file
15
Task/File-IO/XPL0/file-io.xpl0
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
include c:\cxpl\codes;
|
||||
int I, C;
|
||||
char IntermediateVariable;
|
||||
[IntermediateVariable:= GetHp;
|
||||
I:= 0;
|
||||
repeat C:= ChIn(1);
|
||||
IntermediateVariable(I):= C;
|
||||
I:= I+1;
|
||||
until C = $1A; \EOF
|
||||
I:= 0;
|
||||
repeat C:= IntermediateVariable(I);
|
||||
I:= I+1;
|
||||
ChOut(0, C);
|
||||
until C = $1A; \EOF
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue