001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.io; 018 019import java.io.IOException; 020import java.io.OutputStream; 021 022/** 023 * Extended interface for a resource that supports writing to it. 024 * Provides an {@link #getOutputStream() OutputStream accessor}. 025 * 026 * @author Juergen Hoeller 027 * @since 3.1 028 * @see java.io.OutputStream 029 */ 030public interface WritableResource extends Resource { 031 032 /** 033 * Return whether the contents of this resource can be modified, 034 * e.g. via {@link #getOutputStream()} or {@link #getFile()}. 035 * <p>Will be {@code true} for typical resource descriptors; 036 * note that actual content writing may still fail when attempted. 037 * However, a value of {@code false} is a definitive indication 038 * that the resource content cannot be modified. 039 * @see #getOutputStream() 040 * @see #isReadable() 041 */ 042 boolean isWritable(); 043 044 /** 045 * Return an {@link OutputStream} for the underlying resource, 046 * allowing to (over-)write its content. 047 * @throws IOException if the stream could not be opened 048 * @see #getInputStream() 049 */ 050 OutputStream getOutputStream() throws IOException; 051 052}