I want to write a class MapWriter<T>
that Implements a Consumer of Map<T,Integer>
that writes the input map into a text file. I have a final attribute outputFilePathStr.
@AllArgsConstructor
public class MapWriter<T> implements Consumer<Map<T,Integer>>{
private final String outputFilePathStr;
@Override
public void accept(Map<T, Integer> tIntegerMap) {
Files.write(outputFilePathStr, tIntegerMap);
}
}
I have an error in Files.write(outputFilePathStr, tIntegerMap), i can't compile it.
P.S: The annotation
@AllArgsConstructor
is from Lombok plugin, it generates automatically all the constructors.
I resolved it. i changed this:
Files.write(outputFilePathStr, tIntegerMap.toString().getBytes())