First week of Java, and I feel like a god tier programmer. Challenge me /g/
Read a text file and output its contents but justified, meaning each line has the same width.
>>57879360
Woah man that's cruel.
I've been using Java on and off for years and I still have to use google whenever I want to read a file.
>>57879395
>Files.readAllLines() is too hard for me
>>57879619
Sometimes the file is not text.
Sometimes the file is too big to load into memory.
Create a try block without a catch or finally, doesn't matter what it does as long as it compiles
I read this from a pajeet book
>>57879644
>Sometimes the file is too big to load into memory.
what is a buffer?
>>57879782
Point is that readAllLines() isn't always the solution and there's like a hundred ways to handle paths and files, io, nio, whatever.
>>57879204function isUsingJava()
return lang
end
local user = (you)
if user and isUsingJava("Java") then
print("die in a fire")
end
>>57879819File fp = new File("/path/to/file")
InputStream in = new FileInputStream(fp);
byte[] buf = new byte[4096];
int read;
while ((read = in.read(buf)) != -1) {
/* handle ${read} bytes of data */
}
what's so challenging
>>57879863
>>>>>>>>>>Lua
>>57879895
is sexy, i know.
>>57879204
Create a caesar cypher
>>57879204
Dunning Kruger effect