java - Designing API for writing to file -
i have networking library can configured write traffic parsed strings specified file. in other words, had method signature this:
public void setfiletowriteto(file file)
and intent user can later, either manually or programmatically, read file string , perform more operations. realized user may not want write file. furthermore, having lot of trouble writing proper unit tests because can't find way mock file.class. alternative design should use both flexible user , testable on end? have considered allowing user pass in outputstream or writer instance instead of file not sure best. thanks!
ask user pass outputstream
. if necessary, can later overload method , ask them pass writer
.
both of these systems included in java.io
see no reason write own.
Comments
Post a Comment