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,52 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
parse arg inFileName lineNr .
if inFileName = '' | inFileName = '.' then inFileName = './data/input.txt'
if lineNr = '' | lineNr = '.' then lineNr = 7
do
lineTxt = readLine(inFileName, lineNr)
say '<textline number="'lineNr.right(5, 0)'">'lineTxt'</textline>'
catch ex = Exception
ex.printStackTrace()
end
return
-- =============================================================================
-- NetRexx/Java programs don't have a special mechanism to seek to a specified line number
-- the simple solution is to iterate through file. (Costly for very large files)
method readLine(inFileName, lineNr) public static signals IOException, FileNotFoundException
lineReader = LineNumberReader(FileReader(File(inFileName)))
notFound = isTrue
lineTxt = ''
loop label reading forever
line = lineReader.readLine()
select
when lineReader.getLineNumber() = lineNr then do
lineTxt = line
notFound = isFalse
leave reading -- terminate I/O loop
end
when line = null then do
leave reading -- terminate I/O loop
end
otherwise nop
end
finally
lineReader.close()
end reading
if notFound then signal RuntimeException('File' inFileName 'does not contain line' lineNr.right(5))
return lineTxt
-- =============================================================================
method isTrue() public static returns boolean
return 1 == 1
-- =============================================================================
method isFalse() public static returns boolean
return \(1 == 1)