Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/Read_entire_file
note: File handling

View file

@ -0,0 +1,11 @@
;Task:
Load the entire contents of some text file as a single string variable.
If applicable, discuss: encoding selection, the possibility of memory-mapping.
Of course, in practice one should avoid reading an entire file at once
if the file is large and the task can be accomplished incrementally instead
(in which case check [[File IO]]);
this is for those cases where having the entire file is actually what is wanted.
<br><br>

View file

@ -0,0 +1 @@
File(filename).read()

View file

@ -0,0 +1 @@
"somefile.txt" f:slurp >s

View file

@ -0,0 +1,7 @@
MODE BOOK = FLEX[0]FLEX[0]FLEX[0]CHAR; ¢ pages of lines of characters ¢
BOOK book;
FILE book file;
INT errno = open(book file, "book.txt", stand in channel);
get(book file, book)

View file

@ -0,0 +1,2 @@
FILE cached book file;
associate(cached book file, book)

View file

@ -0,0 +1 @@
val s = fileref_get_file_string (stdin_ref)

View file

@ -0,0 +1,13 @@
#!/usr/bin/awk -f
BEGIN {
## empty record separate,
RS="";
## read line (i.e. whole file) into $0
getline;
## print line number and content of line
print "=== line "NR,":",$0;
}
{
## no further line is read printed
print "=== line "NR,":",$0;
}

View file

@ -0,0 +1,10 @@
#!/usr/bin/awk -f
@include "readfile"
BEGIN {
str = readfile("file.txt")
print str
}

View file

@ -0,0 +1,6 @@
proc MAIN()
char array STRING
open (1,"D:FILE.TXT",4,0)
inputsd(1,STRING)
close(1)
return

View file

@ -0,0 +1,23 @@
with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;

View file

@ -0,0 +1,35 @@
with Ada.Text_IO,
POSIX.IO,
POSIX.Memory_Mapping,
System.Storage_Elements;
procedure Read_Entire_File is
use POSIX, POSIX.IO, POSIX.Memory_Mapping;
use System.Storage_Elements;
Text_File : File_Descriptor;
Text_Size : System.Storage_Elements.Storage_Offset;
Text_Address : System.Address;
begin
Text_File := Open (Name => "read_entire_file.adb",
Mode => Read_Only);
Text_Size := Storage_Offset (File_Size (Text_File));
Text_Address := Map_Memory (Length => Text_Size,
Protection => Allow_Read,
Mapping => Map_Shared,
File => Text_File,
Offset => 0);
declare
Text : String (1 .. Natural (Text_Size));
for Text'Address use Text_Address;
begin
Ada.Text_IO.Put (Text);
end;
Unmap_Memory (First => Text_Address,
Length => Text_Size);
Close (File => Text_File);
end Read_Entire_File;

View file

@ -0,0 +1,7 @@
#include <hopper.h>
main:
s=""
load str ("archivo.txt") (s)
println ( "File loaded:\n",s )
exit(0)

View file

@ -0,0 +1,9 @@
set pathToTextFile to ((path to desktop folder as string) & "testfile.txt")
-- short way: open, read and close in one step
set fileContent to read file pathToTextFile
-- long way: open a file reference, read content and close access
set fileRef to open for access pathToTextFile
set fileContent to read fileRef
close access fileRef

View file

@ -0,0 +1,15 @@
100 D$ = CHR$ (4)
110 F$ = "INPUT.TXT"
120 PRINT D$"VERIFY"F$
130 PRINT D$"OPEN"F$
140 PRINT D$"READ"F$
150 ONERR GOTO 210
160 GET C$
170 POKE 216,0
180 S$ = S$ + C$
190 PRINT
200 GOTO 140
210 POKE 216,0
220 EOF = PEEK (222) = 5
230 IF NOT EOF THEN RESUME
240 PRINT D$"CLOSE"F$

View file

@ -0,0 +1 @@
contents: read "input.txt"

View file

@ -0,0 +1 @@
fileread, varname, C:\filename.txt ; adding "MsgBox %varname%" (no quotes) to the next line will display the file contents.

View file

@ -0,0 +1,3 @@
$fileOpen = FileOpen("file.txt")
$fileRead = FileRead($fileOpen)
FileClose($fileOpen)

View file

@ -0,0 +1,5 @@
DIM f AS STRING
OPEN "file.txt" FOR BINARY AS 1
f = SPACE$(LOF(1))
GET #1, 1, f
CLOSE 1

View file

@ -0,0 +1,7 @@
f = freefile
open f, "input.txt"
while not eof(f)
linea$ = readline(f)
print linea$
end while
close f

View file

@ -0,0 +1,6 @@
file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%

View file

@ -0,0 +1,4 @@
file% = OPENIN("input.txt")
strvar$ = STRING$(EXT#file%, " ")
SYS "ReadFile", @hfile%(file%), !^strvar$, EXT#file%, ^temp%, 0
CLOSE #file%

View file

@ -0,0 +1,6 @@
•file.Chars "file"
•file.Bytes "file"
# Shorthands:
•FChars "file"
•FBytes "file"

View file

@ -0,0 +1 @@
content$ = LOAD$(filename$)

View file

@ -0,0 +1,3 @@
binary = BLOAD("somefile.bin")
PRINT "First two bytes are: ", PEEK(binary), " ", PEEK(binary+1)
FREE binary

View file

@ -0,0 +1,47 @@
global _start
: syscall ( num:eax -- result:eax ) syscall ;
: exit ( status:edi -- noret ) 60 syscall ;
: bye ( -- noret ) 0 exit ;
: die ( err:eax -- noret ) neg exit ;
: unwrap ( result:eax -- value:eax ) dup 0 cmp ' die xl ;
: ordie ( result -- ) unwrap drop ;
: open ( pathname:edi flags:esi -- fd:eax ) 2 syscall unwrap ;
: close ( fd:edi -- ) 3 syscall ordie ;
48 resb stat_buf
8 resb file-size
88 resb padding
: fstat ( fd:edi buf:esi -- ) 5 syscall ordie ;
1 const prot_read
2 const map_private
: mmap ( fd:r8d len:esi addr:edi off:r9d prot:edx flags:r10d -- buf:eax ) 9 syscall unwrap ;
: munmap ( addr:edi len:esi -- ) 11 syscall ordie ;
1 resd fd
0 const read-only
: open-file ( pathname:edi -- ) read-only open fd ! ;
: read-file-size ( -- ) fd @ stat_buf fstat ;
: map-file ( fd len -- buf ) 0 0 prot_read map_private mmap ;
: map-file ( -- buf ) fd @ file-size @ map-file ;
: unmap-file ( buf -- ) file-size @ munmap ;
: close-file ( -- ) fd @ close ;
: open-this-file ( -- ) s" read_entire_file.blue" drop open-file ;
: _start ( -- noret )
open-this-file
read-file-size
map-file
\ do something ...
unmap-file
close-file
bye
;

View file

@ -0,0 +1,4 @@
> Keep cell 0 at 0 as a sentinel value
,[>,] Read into successive cells until EOF
<[<] Go all the way back to the beginning
>[.>] Print successive cells while nonzero

View file

@ -0,0 +1,3 @@
include :file
file.read file_name

View file

@ -0,0 +1,23 @@
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
int main( )
{
if (std::ifstream infile("sample.txt"))
{
// construct string from iterator range
std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>());
cout << "File has " << fileData.size() << "chars\n";
// don't need to manually close the ifstream; it will release the file when it goes out of scope
return 0;
}
else
{
std::cout << "file not found!\n";
return 1;
}
}

View file

@ -0,0 +1,10 @@
using System.IO;
class Program
{
static void Main(string[] args)
{
var fileContents = File.ReadAllText("c:\\autoexec.bat");
// Can optionally take a second parameter to specify the encoding, e.g. File.ReadAllText("c:\\autoexec.bat", Encoding.UTF8)
}
}

View file

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
// we can now close the file
fclose(fh); fh = NULL;
// do something, e.g.
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
char *buffer;
struct stat s;
int fd = open("readentirefile_mm.c", O_RDONLY);
if (fd < 0 ) return EXIT_FAILURE;
fstat(fd, &s);
/* PROT_READ disallows writing to buffer: will segv */
buffer = mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if ( buffer != (void*)-1 )
{
/* do something */
fwrite(buffer, s.st_size, 1, stdout);
munmap(buffer, s.st_size);
}
close(fd);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,19 @@
#include <windows.h>
#include <stdio.h>
int main() {
HANDLE hFile, hMap;
DWORD filesize;
char *p;
hFile = CreateFile("mmap_win.c", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
filesize = GetFileSize(hFile, NULL);
hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
p = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
fwrite(p, filesize, 1, stdout);
CloseHandle(hMap);
CloseHandle(hFile);
return 0;
}

View file

@ -0,0 +1 @@
file(READ /etc/passwd string)

View file

@ -0,0 +1 @@
file(READ /etc/pwd.db string HEX)

View file

@ -0,0 +1,2 @@
(slurp "myfile.txt")
(slurp "my-utf8-file.txt" "UTF-8")

View file

@ -0,0 +1,14 @@
10 rem load the entire contents of some text file as a single string variable.
20 rem should avoid reading an entire file at once if the file is large
30 rem ================================
40 print chr$(14) : rem switch to upper+lowercase character set
50 open 4,8,4,"data.txt,seq,read"
60 n=0
70 for i=0 to 1
80 get#4,x$
90 i=st and 64 : rem check for 'end-of-file'
100 if i=0 then a$=a$+x$ : n=n+1
110 if n=255 then i=1 : rem max string length is 255 only
120 next
130 close 4
140 end

View file

@ -0,0 +1,5 @@
(defun file-string (path)
(with-open-file (stream path)
(let ((data (make-string (file-length stream))))
(read-sequence data stream)
data)))

View file

@ -0,0 +1,2 @@
content = File.read("input.txt")
puts content

View file

@ -0,0 +1 @@
content = File.read("input.txt", "UTF-16")

View file

@ -0,0 +1 @@
content = File.read("input.txt", encoding: "UTF-16")

View file

@ -0,0 +1,3 @@
content = File.open("input.txt") do |file|
file.gets_to_end
end

View file

@ -0,0 +1,3 @@
file = File.new("input.txt")
content = file.gets_to_end
file.close

View file

@ -0,0 +1,9 @@
import std.file: read, readText;
void main() {
// To read a whole file into a dynamic array of unsigned bytes:
auto data = cast(ubyte[])read("unixdict.txt");
// To read a whole file into a validated UTF-8 string:
string txt = readText("unixdict.txt");
}

View file

@ -0,0 +1,22 @@
program ReadAll;
{$APPTYPE CONSOLE}
uses Classes;
var
i: Integer;
lList: TStringList;
begin
lList := TStringList.Create;
try
lList.LoadFromFile('c:\input.txt');
// Write everything at once
Writeln(lList.Text);
// Write one line at a time
for i := 0 to lList.Count - 1 do
Writeln(lList[i]);
finally
lList.Free;
end;
end.

View file

@ -0,0 +1,14 @@
program ReadAll;
{$APPTYPE CONSOLE}
uses
SysUtils, IOUtils;
begin
// with default encoding:
Writeln(TFile.ReadAllText('C:\autoexec.bat'));
// with encoding specified:
Writeln(TFile.ReadAllText('C:\autoexec.bat', TEncoding.ASCII));
Readln;
end.

View file

@ -0,0 +1 @@
<file:foo.txt>.getText()

View file

@ -0,0 +1,3 @@
static Byte[] contentsOf(File file) {
return file.contents;
}

View file

@ -0,0 +1,2 @@
Byte[] bytes = #./checkmark.ico;
String html = $/docs/website/index.htm;

View file

@ -0,0 +1,5 @@
File iconFile = ./checkmark.ico;
File htmlFile = /docs/website/index.htm;
Byte[] bytes = iconFile.contents;
String html = htmlFile.contents.unpackUtf8();

View file

@ -0,0 +1,23 @@
defmodule FileReader do
# Read in the file
def read(path) do
case File.read(path) do
{:ok, body} ->
IO.inspect body
{:error,reason} ->
:file.format_error(reason)
end
end
# Open the file path, then read in the file
def bit_read(path) do
case File.open(path) do
{:ok, file} ->
# :all can be replaced with :line, or with a positive integer to specify the number of characters to read.
IO.read(file,:all)
|> IO.inspect
{:error,reason} ->
:file.format_error(reason)
end
end
end

View file

@ -0,0 +1,3 @@
(setq my-variable (with-temp-buffer
(insert-file-contents "foo.txt")
(buffer-string)))

View file

@ -0,0 +1 @@
{ok, B} = file:read_file("myfile.txt").

View file

@ -0,0 +1,16 @@
function load_file(sequence filename)
integer fn,c
sequence data
fn = open(filename,"r") -- "r" for text files, "rb" for binary files
if (fn = -1) then return {} end if -- failed to open the file
data = {} -- init to empty sequence
c = getc(fn) -- prime the char buffer
while (c != -1) do -- while not EOF
data &= c -- append each character
c = getc(fn) -- next char
end while
close(fn)
return data
end function

View file

@ -0,0 +1,4 @@
// read entire file into variable using default system encoding or with specified encoding
open System.IO
let data = File.ReadAllText(filename)
let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)

View file

@ -0,0 +1,7 @@
USING: io.encodings.ascii io.encodings.binary io.files ;
! to read entire file as binary
"foo.txt" binary file-contents
! to read entire file as lines of text
"foo.txt" ascii file-lines

View file

@ -0,0 +1,8 @@
class ReadString
{
public static Void main (Str[] args)
{
Str contents := File(args[0].toUri).readAllStr
echo ("contents: $contents")
}
}

View file

@ -0,0 +1 @@
s" foo.txt" slurp-file ( str len )

View file

@ -0,0 +1,14 @@
program read_file
implicit none
integer :: n
character(:), allocatable :: s
open(unit=10, file="read_file.f90", action="read", &
form="unformatted", access="stream")
inquire(unit=10, size=n)
allocate(character(n) :: s)
read(10) s
close(10)
print "(A)", s
end program

View file

@ -0,0 +1,22 @@
program file_win
use kernel32
use iso_c_binding
implicit none
integer(HANDLE) :: hFile, hMap, hOutput
integer(DWORD) :: fileSize
integer(LPVOID) :: ptr
integer(LPDWORD) :: charsWritten
integer(BOOL) :: s
hFile = CreateFile("file_win.f90" // c_null_char, GENERIC_READ, &
0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
filesize = GetFileSize(hFile, NULL)
hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)
ptr = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)
hOutput = GetStdHandle(STD_OUTPUT_HANDLE)
s = WriteConsole(hOutput, ptr, fileSize, transfer(c_loc(charsWritten), 0_c_intptr_t), NULL)
s = CloseHandle(hMap)
s = CloseHandle(hFile)
end program

View file

@ -0,0 +1,10 @@
' FB 1.05.0 Win64
Open "input.txt" For Input Encoding "ascii" As #1
Dim fileLen As LongInt = Lof(1) '' get file length in bytes
Dim buffer As String = Space(fileLen) '' allocate a string of size 'fileLen' bytes
Get #1, 1, buffer '' read all data from start of file into the buffer
Print buffer '' print to console
buffer = "" '' release memory used by setting buffer to empty
Close #1
Sleep

View file

@ -0,0 +1,2 @@
a = read["file:yourfile.txt"]
b = read["file:yourfile.txt", "UTF-8"]

View file

@ -0,0 +1,29 @@
_window = 1
begin enum 1
_scrollView
_textView
end enum
void local fn BuildWindow
CGRect r = {0,0,550,400}
window _window, @"Read Entire File", r
scrollview _scrollView, r
ViewSetAutoresizingMask( _scrollView, NSViewWidthSizable + NSViewHeightSizable )
textview _textView,, _scrollView
end fn
local fn ReadTextFile
CFStringRef string
CFURLRef url = openpanel 1, @"Select text file..."
if ( url )
string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
TextSetString( _textView, string )
else
// user cancelled
end if
end fn
fn BuildWindow
fn ReadTextFile
HandleEvents

View file

@ -0,0 +1,3 @@
InputTextFile("input.txt");
s := ReadAll(f);; # two semicolons to hide the result, which may be long
CloseStream(f);

View file

@ -0,0 +1 @@
Start,Programs,Accessories,Notepad,Menu:File,Open,Doubleclick:Icon:Notes.TXT,Button:OK

View file

@ -0,0 +1,6 @@
Public Sub Form_Open()
Dim sFile As String
sFile = File.Load(User.home &/ "file.txt")
End

View file

@ -0,0 +1,21 @@
[indent=4]
/*
Read entire file, in Genie
valac readEntireFile.gs
./readEntireFile [filename]
*/
init
fileName:string
fileContents:string
fileName = (args[1] is null) ? "readEntireFile.gs" : args[1]
try
FileUtils.get_contents(fileName, out fileContents)
except exc:Error
print "Error: %s", exc.message
return
stdout.printf("%d bytes read from %s\n", fileContents.length, fileName)

View file

@ -0,0 +1,4 @@
import "io/ioutil"
data, err := ioutil.ReadFile(filename)
sv := string(data)

View file

@ -0,0 +1,27 @@
// +build !windows,!plan9,!nacl // These lack syscall.Mmap
package main
import (
"fmt"
"log"
"os"
"syscall"
)
func main() {
f, err := os.Open("file")
if err != nil {
log.Fatal(err)
}
fi, err := f.Stat()
if err != nil {
log.Fatal(err)
}
data, err := syscall.Mmap(int(f.Fd()), 0, int(fi.Size()),
syscall.PROT_READ, syscall.MAP_PRIVATE)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
}

View file

@ -0,0 +1 @@
def fileContent = new File("c:\\file.txt").text

View file

@ -0,0 +1,2 @@
do text <- readFile filepath
-- do stuff with text

View file

@ -0,0 +1,4 @@
eagerReadFile :: FilePath -> IO String
eagerReadFile filepath = do
text <- readFile filepath
last text `seq` return text

View file

@ -0,0 +1 @@
every (fs := "") ||:= |reads(1000000)

View file

@ -0,0 +1,3 @@
every put(fL := [],|FUNC(read()))
every (fs := "") ||:= !fL || "\n"
fL := &null

View file

@ -0,0 +1,7 @@
Home is a room.
The File of Testing is called "test".
When play begins:
say "[text of the File of Testing]";
end the story.

View file

@ -0,0 +1,2 @@
require 'files' NB. not needed for J7 & later
var=: fread 'foo.txt'

View file

@ -0,0 +1,2 @@
require 'jmf'
JCHAR map_jmf_ 'var';'foo.txt'

View file

@ -0,0 +1,10 @@
fn main() {
let filename = "Read_entire_file.jakt"
mut file = File::open_for_reading(filename)
mut builder = StringBuilder::create()
for byte in file.read_all() {
builder.append(byte)
}
let contents = builder.to_string()
println("{}", contents)
}

View file

@ -0,0 +1,22 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static void main(String[] args) throws IOException{
String fileContents = readEntireFile("./foo.txt");
}
private static String readEntireFile(String filename) throws IOException {
FileReader in = new FileReader(filename);
StringBuilder contents = new StringBuilder();
char[] buffer = new char[4096];
int read = 0;
do {
contents.append(buffer, 0, read);
read = in.read(buffer);
} while (read >= 0);
in.close();
return contents.toString();
}
}

View file

@ -0,0 +1,20 @@
import java.nio.channels.FileChannel.MapMode;
import java.nio.MappedByteBuffer;
import java.io.RandomAccessFile;
import java.io.IOException;
import java.io.File;
public class MMapReadFile {
public static void main(String[] args) throws IOException {
MappedByteBuffer buff = getBufferFor(new File(args[0]));
String results = new String(buff.asCharBuffer());
}
public static MappedByteBuffer getBufferFor(File f) throws IOException {
RandomAccessFile file = new RandomAccessFile(f, "r");
MappedByteBuffer buffer = file.getChannel().map(MapMode.READ_ONLY, 0, f.length());
file.close();
return buffer;
}
}

View file

@ -0,0 +1 @@
String content = new Scanner(new File("foo"), "UTF-8").useDelimiter("\\A").next();

View file

@ -0,0 +1,15 @@
import java.util.List;
import java.nio.charset.Charset;
import java.nio.file.*;
public class ReadAll {
public static List<String> readAllLines(String filesname){
Path file = Paths.get(filename);
return Files.readAllLines(file, Charset.defaultCharset());
}
public static byte[] readAllBytes(String filename){
Path file = Paths.get(filename);
return Files.readAllBytes(file);
}
}

View file

@ -0,0 +1,5 @@
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f=fso.OpenTextFile("c:\\myfile.txt",1);
var s=f.ReadAll();
f.Close();
try{alert(s)}catch(e){WScript.Echo(s)}

View file

@ -0,0 +1,14 @@
var file = document.getElementById("fileInput").files.item(0); //a file input element
if (file) {
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = loadedFile;
reader.onerror = errorHandler;
}
function loadedFile(event) {
var fileString = event.target.result;
alert(fileString);
}
function errorHandler(event) {
alert(event);
}

View file

@ -0,0 +1 @@
jq -R -s . input.txt

View file

@ -0,0 +1 @@
jq -R . input.txt | jq -s .

View file

@ -0,0 +1 @@
jq -R -s 'split("\n")' input.txt

View file

@ -0,0 +1 @@
var contents = File.read("filename")

View file

@ -0,0 +1 @@
read("/devel/myfile.txt", String) # read file into a string

View file

@ -0,0 +1 @@
A = Mmap.mmap(open("/devel/myfile.txt"), Array{UInt8,1})

View file

@ -0,0 +1 @@
`c$1:"example.txt"

View file

@ -0,0 +1 @@
0:"example.txt"

View file

@ -0,0 +1 @@
content ← io:readFile "file.txt"

View file

@ -0,0 +1 @@
content ← io:read "file.txt"

View file

@ -0,0 +1,5 @@
import java.io.File
fun main(args: Array<String>) {
println(File("unixdict.txt").readText(charset = Charsets.UTF_8))
}

View file

@ -0,0 +1 @@
(set `#(ok ,data) (file:read_file "myfile.txt"))

View file

@ -0,0 +1 @@
'foo.txt slurp

View file

@ -0,0 +1,2 @@
local(f) = file('foo.txt')
#f->readString

View file

@ -0,0 +1,7 @@
filedialog "Open a Text File","*.txt",file$
if file$<>"" then
open file$ for input as #1
entire$ = input$(#1, lof(#1))
close #1
print entire$
end if

View file

@ -0,0 +1,13 @@
----------------------------------------
-- Reads whole file, returns string
-- @param {string} tFile
-- @return {string|false}
----------------------------------------
on readFile (tFile)
fp = xtra("fileIO").new()
fp.openFile(tFile, 1)
if fp.status() then return false
res = fp.readFile()
fp.closeFile()
return res
end

Some files were not shown because too many files have changed in this diff Show more