#Read file lines
1 messages · Page 1 of 1 (latest)
i believe theres snippets in #skript-snippets
or if you want I can dig around and see if I have any
Thanks.
Hey couldn't find anything I could understand or give an idea where to start, any chance you for further help ?
I should proberly add - Preferably no addon, than skript it self and perhaps skript-reflect please
java.io.File
java.util.Scanner
java.io.FileWriter
java.nio.file.Files
java.nio.file.Path
options:
in: ([with]in|from)
plural expression [all] lines {@in} file %string%:
return type: strings
get:
set {_path} to expr-1
return ...Files.readAllLines((new File({_path})).toPath())```this is a part of my files stuff, you dont need all the imports for this but if you plan on doing more (ie writing to files too) then you'll need them
reflect will be needed
Your the best, also how do I use it ? I mean can I loop through it and so forth ?
yup, this code just adds the expression, so you can do things like
set {_lines::*} to lines from file "example/file.txt"
Thank you so much, last question - How's the performance ?
i dont think you need to worry about that
because it's not effecting much, or something else ? - I am using it quite often
one more question.. sorry - instead of reading all lines from file, can I just read one line by using the API feature, so I don't have to do it through skript
yes, I've made an expression for that too--ill send it tomorrow
(because it actually already is tomorrow for me lol)
okay, i've done a decent explanation of it here:
https://x8ight.gitbook.io/scripts/files