java - How do I do this using guava? -


Is there a way to get down using accusations?

  // Using files.append () in a loop? Org.apache.commons.io.FileUtils.writeLines (file files, archive lines, string lineending); // gives a byte [] that is fed to files. Write (byte [], from file) org.apache.commons.lang.SerializationUtils.sialialize (serialable obz) // Receive an object from a byte [SerializationUtils. SerializationUtils.deserialize (byte [])  

Thanks.

For the first, an option would be:

  files.write (Joiner.lineending) .join (line), file, charset);  

I do not know that it is faster than engaging in the loop (and of course it also includes another string based on lines), but it reads well.

For the other two ... Guava does not really provide anything specific for serialization, he said, if you want you can build some good utilities at the top of Gao's Io support Moving through an intermediate byte [] seems to be useless for serializing or decryizing objects, when you can read / write objects directly from a stream, such methods Ikna quite simple:

  void Siriyllaijh (does Autputshapar & lt; Autputstrym & gt; output Autputstrym, expand Object object) throws IOException; Object throws IOException, spreads in the object deserillise (InputSpplar & # 39; inststream> inputspliers); class notfound exception;  

Comments