<h2>org.das2.util.FileUtil</h2><p>static utility methods.
 
 introduced Jul 28, 2008.</p>
<hr>
<a name="consumeStream"></a>
<h2>consumeStream</h2>
consumeStream( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html'>java.io.InputStream</a> in ) &rarr; int

<p>read all the bytes off the stream, perhaps to empty a URL response.  This
 does not close the stream!</p>

<h3>Parameters</h3>
in - the input stream, which will not be closed by this method.

<h3>Returns:</h3>
the total number of bytes read.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=consumeStream&unscoped_q=consumeStream">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#consumeStream">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="deleteFileTree"></a>
<h2>deleteFileTree</h2>
deleteFileTree( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root ) &rarr; boolean

<p>deletes all files and folders below root, and root, just as "rm -r" would.
 TODO: check links</p>

<h3>Parameters</h3>
root - the root where we start deleting.

<h3>Returns:</h3>
true if the operation was successful.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=deleteFileTree&unscoped_q=deleteFileTree">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#deleteFileTree">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
deleteFileTree( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/Set.html'>java.util.Set</a> exclude ) &rarr; boolean<br>
<hr>
<a name="deleteWithinFileTree"></a>
<h2>deleteWithinFileTree</h2>
deleteWithinFileTree( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root, <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> name ) &rarr; boolean

<p>deletes all files with the given name, and root, just as "find . -name name -exec rm {} \;" would.
 TODO: check links.  For example deleteWithinFileTree( root, ".listing" )</p>

<h3>Parameters</h3>
root - the root directory of the tree.
<br>
name - the file name.

<h3>Returns:</h3>
true if the operation was successful.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=deleteWithinFileTree&unscoped_q=deleteWithinFileTree">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#deleteWithinFileTree">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="fileCompare"></a>
<h2>fileCompare</h2>
fileCompare( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> file1, <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> file2 ) &rarr; boolean

<p>returns True if the file contents are equal.</p>

<h3>Parameters</h3>
file1 - a File
<br>
file2 - a File

<h3>Returns:</h3>
true if the two files have identical
<br><br>
<a href="https://github.com/autoplot/dev/search?q=fileCompare&unscoped_q=fileCompare">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#fileCompare">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="fileCopy"></a>
<h2>fileCopy</h2>
fileCopy( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> src, <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> dst ) &rarr; void

<p>copies the file or folder from src to dst.</p>

<h3>Parameters</h3>
src - the source file or folder.
<br>
dst - the location for the new file or folder.

<h3>Returns:</h3>
void (returns nothing)

<br><br>
<a href="https://github.com/autoplot/dev/search?q=fileCopy&unscoped_q=fileCopy">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#fileCopy">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="find"></a>
<h2>find</h2>
find( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root, <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> name ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a>

<p>find a files with the given name within the given root, just as "find . -name name -print \;" would.
 TODO: check links.  For example, find( "/usr/share/fonts/truetype", "FreeMono.ttf" )</p>

<h3>Parameters</h3>
root - the root to start
<br>
name - name to look for.

<h3>Returns:</h3>
the File found, or null if it does not exist.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=find&unscoped_q=find">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#find">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
find( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html'>java.util.regex.Pattern</a> pattern, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/List.html'>java.util.List</a> result ) &rarr; int<br>
find( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File[]</a> roots, <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> name ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a><br>
<hr>
<a name="getMagic"></a>
<h2>getMagic</h2>
getMagic( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> src ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a>

<p>return the first four bytes of the file as a string.  Some magic
 numbers we care about:
  <li> '\x89HDF'  HDF (and new NetCDF) files</p>

<h3>Parameters</h3>
src - a File

<h3>Returns:</h3>
a four byte string
<br><br>
<a href="https://github.com/autoplot/dev/search?q=getMagic&unscoped_q=getMagic">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#getMagic">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="isParent"></a>
<h2>isParent</h2>
isParent( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> possibleParent, <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> maybeChild ) &rarr; boolean

<p>return true of the maybeChild parent is a child of possibleParent.  Note either
 can be null, and this will not throw an exception, but will return false.</p>

<h3>Parameters</h3>
possibleParent - parent file.
<br>
maybeChild - a file or folder which may exist within possibleParent.

<h3>Returns:</h3>
true if the possibleParent is actually a parent of maybeChild.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=isParent&unscoped_q=isParent">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#isParent">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="lineCount"></a>
<h2>lineCount</h2>
lineCount( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> f ) &rarr; int

<p>return the number of lines in the text file.  Breaking the file into
 lines is handled by Java's BufferedReader.</p>

<h3>Parameters</h3>
f - the file

<h3>Returns:</h3>
the number of lines.
<h3>See Also:</h3>
<a href='null'>BufferedReader</a> <br>
<br><br>
<a href="https://github.com/autoplot/dev/search?q=lineCount&unscoped_q=lineCount">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#lineCount">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="listRecursively"></a>
<h2>listRecursively</h2>
listRecursively( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html'>java.util.regex.Pattern</a> name, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/List.html'>java.util.List</a> matches ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/util/List.html'>java.util.List</a>

<p>find all files under the root matching the spec.</p>

<h3>Parameters</h3>
root - the root of the search (e.g. /fonts/)
<br>
name - the pattern to match
<br>
matches - list that will accept the matches, or null if one should be created.

<h3>Returns:</h3>
the list.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=listRecursively&unscoped_q=listRecursively">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#listRecursively">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
listRecursively( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> root, <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> glob ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File[]</a><br>
<hr>
<a name="readFileToString"></a>
<h2>readFileToString</h2>
readFileToString( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> f ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a>

<p>read all the bytes in the UTF-8 encoded file into a string.</p>

<h3>Parameters</h3>
f - the file, which presumed to be UTF-8 (or ASCII) encoded.

<h3>Returns:</h3>
string containing the contents of the file.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=readFileToString&unscoped_q=readFileToString">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#readFileToString">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="readInputStreamToString"></a>
<h2>readInputStreamToString</h2>
readInputStreamToString( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html'>java.io.InputStream</a> ins ) &rarr; <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a>

<p>read all the bytes in the UTF-8 encoded inputStream into a string.</p>

<h3>Parameters</h3>
ins - the input stream

<h3>Returns:</h3>
string containing the contents of the file.
<br><br>
<a href="https://github.com/autoplot/dev/search?q=readInputStreamToString&unscoped_q=readInputStreamToString">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#readInputStreamToString">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>
<hr>
<a name="writeStringToFile"></a>
<h2>writeStringToFile</h2>
writeStringToFile( <a href='https://docs.oracle.com/javase/8/docs/api/java/io/File.html'>java.io.File</a> f, <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> src ) &rarr; void

<p>write all the bytes in the string to a file using UTF-8 encoding.</p>

<h3>Parameters</h3>
f - the file name.
<br>
src - the string to write to the file.

<h3>Returns:</h3>
void (returns nothing)

<br><br>
<a href="https://github.com/autoplot/dev/search?q=writeStringToFile&unscoped_q=writeStringToFile">[search for examples]</a>
 <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/das2/util/FileUtil.md">[view on GitHub]</a>
 <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/das2/util/FileUtil.html#writeStringToFile">[view on old javadoc]</a>
 <a href="https://saturn.physics.uiowa.edu/svn/das2/dasCore/community/autoplot2011/trunk/dasCoreUtil/src/org/das2/util/FileUtil.java">[view source]</a>
<br>
<br>