It seems that I'm the only one who didn't get this one, and this is very frustrating. ¯\_(ツ)_/¯
Anyway, I tried to follow the steps of the requirements, but I really don't understand what this task is about, or what I have to do. I looked at the only two other help topics and still didn't get it...
Any clarification would be very appreciated.
Thanks!
(Now I'm gonna cry in fetal position while I wait for an answer)
package com.codegym.task.task19.task1917;
/*
Your own FileWriter
*/
import java.io.FileWriter;
import java.io.IOException;
public class FileConsoleWriter {
private FileWriter fileWriter;
public static void main(String[] args) {
}
public FileConsoleWriter(char[] cbuf, int off, int len) throws IOException {
fileWriter.write(cbuf, off, len);
}
public FileConsoleWriter(int c) throws IOException {
fileWriter.write(c);
}
public FileConsoleWriter(String str) throws IOException {
fileWriter.write(str);
}
public FileConsoleWriter(String str, int off, int len) throws IOException {
fileWriter.write(str, off, len);
}
public FileConsoleWriter(char[] cbuf) throws IOException {
fileWriter.write(cbuf);
}
public void write(char[] cbuf, int off, int len) throws IOException {
}
public void write(int c) throws IOException {
}
public void write(String str) throws IOException {
}
public void write(String str, int off, int len) throws IOException {
}
public void write(char[] cbuf) throws IOException {
}
public void close() throws IOException {
}
}
Here, on my intelliJ(see pic) it shows:
1) String fileName
2) String fileName, boolean append
3) File file
4) File file, boolean append
5) FileDescriptor fd
6) String fileName, Charset charset
7) String fileName, Charset charset, boolean append
8) File file, Charset charset
9) File file, Charset charset, boolean append
So the constructors of FileConsoleWriter must be analogous to FileWriter constructors, so that we can initialize the "fileWriter" object in it?
Ok, now the constructors part is clearer to me.
--
Still, I'd like to ask you some things about the methods, if you don't mind.
So this is what I understood about the methods:
Each "write" method on FileConsoleWriter must call a equivalent "write" method of the FileWrite class. To do so, we must use the FileWriter object called "fileWriter".
I think I understand most of the methods used, but I'm having a hard time with the ones with "off, len":
I didn't check the task yet, so I don't know if this code is correct. But the others wrote like this, so it's probably correct or close to.
Why do we have to write "off + i" in the first case and "off + len" in the second case?
I've read everywhere that "off" is "offset", and I don't know exactly what this word means. I couldn't find a translation to Portuguese (my first language) that made sense to me. And "len" is the length of the array/string, right?
Well, as you can see I still don't understand everything, but your help was crucial to put me on the right way to begin to underst