43 lines
962 B
Text
43 lines
962 B
Text
/* NetRexx */
|
|
options replace format comments java crossref symbols nobinary
|
|
|
|
parse arg inFileName .
|
|
|
|
if inFileName = '' | inFileName = '.' then inFileName = './data/dwarfs.json'
|
|
fileContents = slurp(inFileName)
|
|
say fileContents
|
|
|
|
return
|
|
|
|
-- Slurp a file and return contents as a Rexx string
|
|
method slurp(inFileName) public static returns Rexx
|
|
|
|
slurped = Rexx null
|
|
slurpStr = StringBuilder()
|
|
ioBuffer = byte[1024]
|
|
inBytes = int 0
|
|
|
|
do
|
|
inFile = File(inFileName)
|
|
inFileIS = BufferedInputStream(FileInputStream(inFile))
|
|
|
|
loop label ioLoop until inBytes = -1
|
|
slurpStr.append(String(ioBuffer, 0, inBytes))
|
|
inBytes = inFileIS.read(ioBuffer)
|
|
end ioLoop
|
|
|
|
catch exFNF = FileNotFoundException
|
|
exFNF.printStackTrace
|
|
catch exIO = IOException
|
|
exIO.printStackTrace
|
|
finally
|
|
do
|
|
inFileIS.close()
|
|
catch ex = IOException
|
|
ex.printStackTrace
|
|
end
|
|
end
|
|
|
|
slurped = Rexx(slurpStr.toString)
|
|
|
|
return slurped
|