Ioutils for commons-io Learning

Source: Internet
Author: User
Public class ioutils extends objectgeneral Io stream manipulation utilities. public static Boolean contentequals (inputstream input1, inputstream input2) throws ioexception is used to compare whether the content in two files is consistent public static Boolean contentequals (Reader input1, reader input2) throws ioexception is used to compare whether the content in two files is consistent. Public static int copy (inputstream input, outputstream output) throws ioexceptionpublic static void copy (inputstream Input, writer output) throws ioexceptionioutils. copy (New fileinputstream (new file ("E:/1.txt"), new fileoutputstream (new file (" F:/1.txt"); public static long copylarge (inputstream input, outputstream output) throws ioexceptionpublic static long copylarge (Reader Input, writer output) throws ioexceptionpublic static void copy (Reader Input, outputstream output) throws ioexceptionpublic static void copy (Re Ader input, outputstream output, string encoding) throws ioexceptionpublic static lineiterator (inputstream input, charset encoding) throws writable stream = new fileinputstream (new file ("F:/1.txt ")); try {lineiterator it = ioutils. lineiterator (stream, "UTF-8"); While (it. hasnext () {string line = it. nextline (); system. out. println (line) ;}} finally {ioutils. closequietly (Stream );} Public static lineiterator (Reader reader) return an iterator for the lines in a reader. public static list <string> readlines (inputstream input) throws ioexceptionget the contents of an inputstream as a list of strings, one entry per line, using the default character encoding of the platform. public static inputstream tobufferedinputstream (inputstream input) throws ioexceptionfetches entir E contents of an inputstream and represent same data as result inputstream. public static bufferedreader tobufferedreader (Reader reader) returns the given reader if it is a bufferedreader, otherwise creates a tobufferedreader for the given reader. public static byte [] tobytearray (inputstream input) throws ioexceptionget the contents of an inputstream as a byte []. public static byte [] tobytearray (Indium Utstream input, int size) throws ioexceptionpublic static byte [] tobytearray (Reader Input) throws ioexceptionpublic static byte [] tobytearray (Reader Input, charset encoding) throws ioexceptionpublic static byte [] tobytearray (URI) throws ioexceptionpublic static byte [] tobytearray (URL) throws ioexceptionget the contents of a URL as a byte []. public static char [] tochararray (inputstream is) throws I Oexceptionpublic static char [] tochararray (inputstream is, string encoding) throws ioexceptionpublic static char [] tochararray (inputstream is, charset encoding) throws ioexceptionpublic static charset forname (string charsetname) returns the charset object of the specified charset. Public static inputstream toinputstream (charsequence input) convert the specified charsequence to an input stream, encoded as bytes using the default character encoding of the platform. java. lang interface charsequenceall known subinterfaces: Name all known implementing classes: charbuffer, segment, String, stringbuffer, stringbuilder public static inputstream toinputstream (charsequence input, charset encoding) convert the specified charsequence to an input stream, encoded as bytes using the specified character encoding. public static inputstream toinputstream (charsequence input, string encoding) throws ioexceptionpublic static inputstream toinputstream (string input) public static string tostring (Reader Input) throws ioexceptionpublic static string tostring (URI) throws ioexceptionpublic static string tostring (URI Uri, charset encoding) throws ioexceptionpublic static string tostring (URI Uri, string encoding) throws ioexceptiongets the contents at the given Uri. public static string tostring (URL) throws ioexceptiongets the contents at the given URL. public static void write (byte [] data, outputstream output) throws ioexceptionwrites bytes from a byte [] to an outputstream. public static void write (byte [] data, writer output) throws ioexceptionwrites bytes from a byte [] to chars on a writer using the default character encoding of the platform. public static void write (byte [] data, writer output, charset encoding) throws ioexceptionpublic static void write (char [] data, outputstream output) throws ioexceptionwrites chars from a char [] to bytes on an outputstream.

 

Refer to commons-io API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.