ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/util/IOTools.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/util/IOTools.java
Status
scanned
Type
file
Name
IOTools.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3581 (3.5 KB)
MD5
4fd80e271ff403c5231066716040bfd9
SHA1
b72ac7d656da4f59180648f0e9cbf7a0d761b945
SHA256
f2becad24e107fd1220da8bc1e5fe8b0f7280eb4a15a14e561c2729ad3f74717
SHA512

      
    
SHA1_git
654e7cd1d866d7a84335418be975bf4d70460507
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
IOTools.java | 3.5 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina.util; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; /** * Contains commonly needed I/O-related methods. */ public class IOTools { protected static final int DEFAULT_BUFFER_SIZE = 4 * 1024; // 4k private IOTools() { // Ensure non-instantiability } /** * Read input from reader and write it to writer until there is no more input from reader. * * @param reader the reader to read from. * @param writer the writer to write to. * @param buf the char array to use as a buffer * * @throws IOException IO error */ public static void flow(Reader reader, Writer writer, char[] buf) throws IOException { int numRead; while ((numRead = reader.read(buf)) >= 0) { writer.write(buf, 0, numRead); } } /** * Read input from reader and write it to writer until there is no more input from reader. * * @param reader the reader to read from. * @param writer the writer to write to. * * @throws IOException IO error * * @see #flow( Reader, Writer, char[] ) */ public static void flow(Reader reader, Writer writer) throws IOException { char[] buf = new char[DEFAULT_BUFFER_SIZE]; flow(reader, writer, buf); } /** * Read input from input stream and write it to output stream until there is no more input from input stream using a * new buffer of the default size (4 KiB). * * @param is input stream the input stream to read from. * @param os output stream the output stream to write to. * * @throws IOException If an I/O error occurs during the copy */ public static void flow(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[DEFAULT_BUFFER_SIZE]; int numRead; while ((numRead = is.read(buf)) >= 0) { if (os != null) { os.write(buf, 0, numRead); } } } /** * Read until EOF or the buffer is filled. * * @param is The source to read from * @param buf The buffer to write to * * @return The number of bytes read * * @throws IOException If an I/O error occurs during the read */ public static int readFully(InputStream is, byte[] buf) throws IOException { int bytesRead = 0; int read; while (bytesRead < buf.length && ((read = is.read(buf, bytesRead, buf.length - bytesRead)) >= 0)) { bytesRead += read; } return bytesRead; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
25.76
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9