File: 06-preserve-pre-guava18-methods.patch

package info (click to toggle)
guava-libraries 32.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,472 kB
  • sloc: java: 359,877; xml: 2,612; sh: 34; javascript: 12; makefile: 8
file content (776 lines) | stat: -rw-r--r-- 28,394 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
Description: Preserves some of the methods from the Files, ByteStreams
 and CharStreams classes that were removed in Guava 18. This patch can be
 removed once closure-compiler and gradle switch to Guava 18 or higher.
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/guava/src/com/google/common/io/ByteSink.java
+++ b/guava/src/com/google/common/io/ByteSink.java
@@ -49,7 +49,7 @@
 @J2ktIncompatible
 @GwtIncompatible
 @ElementTypesAreNonnullByDefault
-public abstract class ByteSink {
+public abstract class ByteSink implements OutputSupplier<OutputStream> {
 
   /** Constructor for use by subclasses. */
   protected ByteSink() {}
@@ -73,6 +73,21 @@
   public abstract OutputStream openStream() throws IOException;
 
   /**
+   * This method is a temporary method provided for easing migration from suppliers to sources and
+   * sinks.
+   *
+   * @since 15.0
+   * @deprecated This method is only provided for temporary compatibility with the
+   *     {@link OutputSupplier} interface and should not be called directly. Use
+   *     {@link #openStream} instead. This method is scheduled for removal in Guava 18.0.
+   */
+  @Override
+  @Deprecated
+  public final OutputStream getOutput() throws IOException {
+    return openStream();
+  }
+
+  /**
    * Opens a new buffered {@link OutputStream} for writing to this sink. The returned stream is not
    * required to be a {@link BufferedOutputStream} in order to allow implementations to simply
    * delegate to {@link #openStream()} when the stream returned by that method does not benefit from
--- a/guava/src/com/google/common/io/ByteSource.java
+++ b/guava/src/com/google/common/io/ByteSource.java
@@ -76,7 +76,7 @@
 @J2ktIncompatible
 @GwtIncompatible
 @ElementTypesAreNonnullByDefault
-public abstract class ByteSource {
+public abstract class ByteSource implements InputSupplier<InputStream> {
 
   /** Constructor for use by subclasses. */
   protected ByteSource() {}
@@ -105,6 +105,21 @@
   public abstract InputStream openStream() throws IOException;
 
   /**
+   * This method is a temporary method provided for easing migration from suppliers to sources and
+   * sinks.
+   *
+   * @since 15.0
+   * @deprecated This method is only provided for temporary compatibility with the
+   *     {@link InputSupplier} interface and should not be called directly. Use {@link #openStream}
+   *     instead. This method is scheduled for removal in Guava 18.0.
+   */
+  @Override
+  @Deprecated
+  public final InputStream getInput() throws IOException {
+    return openStream();
+  }
+
+  /**
    * Opens a new buffered {@link InputStream} for reading from this source. The returned stream is
    * not required to be a {@link BufferedInputStream} in order to allow implementations to simply
    * delegate to {@link #openStream()} when the stream returned by that method does not benefit from
--- a/guava/src/com/google/common/io/ByteStreams.java
+++ b/guava/src/com/google/common/io/ByteStreams.java
@@ -23,6 +23,8 @@
 
 import com.google.common.annotations.GwtIncompatible;
 import com.google.common.annotations.J2ktIncompatible;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
 import com.google.common.math.IntMath;
 import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import java.io.ByteArrayInputStream;
@@ -97,6 +99,38 @@
   private ByteStreams() {}
 
   /**
+   * Returns a factory that will supply instances of
+   * {@link ByteArrayInputStream} that read from the given byte array.
+   *
+   * @param b the input buffer
+   * @return the factory
+   * @deprecated Use {@link ByteSource#wrap(byte[])} instead. This method is
+   *     scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<ByteArrayInputStream> newInputStreamSupplier(
+      byte[] b) {
+    return asInputSupplier(ByteSource.wrap(b));
+  }
+
+  /**
+   * Returns a factory that will supply instances of
+   * {@link ByteArrayInputStream} that read from the given byte array.
+   *
+   * @param b the input buffer
+   * @param off the offset in the buffer of the first byte to read
+   * @param len the maximum number of bytes to read from the buffer
+   * @return the factory
+   * @deprecated Use {@code ByteSource.wrap(b).slice(off, len)} instead. This
+   *     method is scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<ByteArrayInputStream> newInputStreamSupplier(
+      final byte[] b, final int off, final int len) {
+    return asInputSupplier(ByteSource.wrap(b).slice(off, len));
+  }
+
+  /**
    * Copies all bytes from the input stream to the output stream. Does not close or flush either
    * stream.
    *
@@ -934,4 +968,141 @@
     }
     return total;
   }
+
+  /**
+   * Returns an {@link InputSupplier} that returns input streams from the
+   * an underlying supplier, where each stream starts at the given
+   * offset and is limited to the specified number of bytes.
+   *
+   * @param supplier the supplier from which to get the raw streams
+   * @param offset the offset in bytes into the underlying stream where
+   *     the returned streams will start
+   * @param length the maximum length of the returned streams
+   * @throws IllegalArgumentException if offset or length are negative
+   * @deprecated Use {@link ByteSource#slice(int, int)} instead. This method is
+   *     scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<InputStream> slice(
+      final InputSupplier<? extends InputStream> supplier,
+      final long offset,
+      final long length) {
+    return asInputSupplier(asByteSource(supplier).slice(offset, length));
+  }
+
+  /**
+   * Joins multiple {@link InputStream} suppliers into a single supplier.
+   * Streams returned from the supplier will contain the concatenated data from
+   * the streams of the underlying suppliers.
+   *
+   * <p>Only one underlying input stream will be open at a time. Closing the
+   * joined stream will close the open underlying stream.
+   *
+   * <p>Reading from the joined stream will throw a {@link NullPointerException}
+   * if any of the suppliers are null or return null.
+   *
+   * @param suppliers the suppliers to concatenate
+   * @return a supplier that will return a stream containing the concatenated
+   *     stream data
+   * @deprecated Use {@link ByteSource#concat(Iterable)} instead. This method
+   *     is scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<InputStream> join(
+      final Iterable<? extends InputSupplier<? extends InputStream>> suppliers) {
+    checkNotNull(suppliers);
+    Iterable<ByteSource> sources = Iterables.transform(suppliers,
+        new Function<InputSupplier<? extends InputStream>, ByteSource>() {
+          @Override
+          public ByteSource apply(InputSupplier<? extends InputStream> input) {
+            return asByteSource(input);
+          }
+        });
+    return asInputSupplier(ByteSource.concat(sources));
+  }
+
+  /**
+   * Varargs form of {@link #join(Iterable)}.
+   *
+   * @deprecated Use {@link ByteSource#concat(ByteSource[])} instead. This
+   *     method is scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  @SuppressWarnings("unchecked") // suppress "possible heap pollution" warning in JDK7
+  public static InputSupplier<InputStream> join(
+      InputSupplier<? extends InputStream>... suppliers) {
+    return join(Arrays.asList(suppliers));
+  }
+
+  /**
+   * Returns a view of the given {@code InputStream} supplier as a
+   * {@code ByteSource}.
+   *
+   * <p>This method is a temporary method provided for easing migration from
+   * suppliers to sources and sinks.
+   *
+   * @since 15.0
+   * @deprecated Convert all {@code InputSupplier<? extends InputStream>}
+   *     implementations to extend {@link ByteSource} or provide a method for
+   *     viewing the object as a {@code ByteSource}. This method is scheduled
+   *     for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static ByteSource asByteSource(
+      final InputSupplier<? extends InputStream> supplier) {
+    checkNotNull(supplier);
+    return new ByteSource() {
+      @Override
+      public InputStream openStream() throws IOException {
+        return supplier.getInput();
+      }
+
+      @Override
+      public String toString() {
+        return "ByteStreams.asByteSource(" + supplier + ")";
+      }
+    };
+  }
+
+  /**
+   * Returns a view of the given {@code OutputStream} supplier as a
+   * {@code ByteSink}.
+   *
+   * <p>This method is a temporary method provided for easing migration from
+   * suppliers to sources and sinks.
+   *
+   * @since 15.0
+   * @deprecated Convert all {@code OutputSupplier<? extends OutputStream>}
+   *     implementations to extend {@link ByteSink} or provide a method for
+   *     viewing the object as a {@code ByteSink}. This method is scheduled
+   *     for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static ByteSink asByteSink(
+      final OutputSupplier<? extends OutputStream> supplier) {
+    checkNotNull(supplier);
+    return new ByteSink() {
+      @Override
+      public OutputStream openStream() throws IOException {
+        return supplier.getOutput();
+      }
+
+      @Override
+      public String toString() {
+        return "ByteStreams.asByteSink(" + supplier + ")";
+      }
+    };
+  }
+
+  @SuppressWarnings("unchecked") // used internally where known to be safe
+  static <S extends InputStream> InputSupplier<S> asInputSupplier(
+      final ByteSource source) {
+    return (InputSupplier) checkNotNull(source);
+  }
+
+  @SuppressWarnings("unchecked") // used internally where known to be safe
+  static <S extends OutputStream> OutputSupplier<S> asOutputSupplier(
+      final ByteSink sink) {
+    return (OutputSupplier) checkNotNull(sink);
+  }
 }
--- a/guava/src/com/google/common/io/CharSink.java
+++ b/guava/src/com/google/common/io/CharSink.java
@@ -53,7 +53,7 @@
 @J2ktIncompatible
 @GwtIncompatible
 @ElementTypesAreNonnullByDefault
-public abstract class CharSink {
+public abstract class CharSink implements OutputSupplier<Writer> {
 
   /** Constructor for use by subclasses. */
   protected CharSink() {}
@@ -69,6 +69,21 @@
   public abstract Writer openStream() throws IOException;
 
   /**
+   * This method is a temporary method provided for easing migration from suppliers to sources and
+   * sinks.
+   *
+   * @since 15.0
+   * @deprecated This method is only provided for temporary compatibility with the
+   *     {@link OutputSupplier} interface and should not be called directly. Use
+   *     {@link #openStream} instead. This method is scheduled for removal in Guava 18.0.
+   */
+  @Override
+  @Deprecated
+  public final Writer getOutput() throws IOException {
+    return openStream();
+  }
+
+  /**
    * Opens a new buffered {@link Writer} for writing to this sink. The returned stream is not
    * required to be a {@link BufferedWriter} in order to allow implementations to simply delegate to
    * {@link #openStream()} when the stream returned by that method does not benefit from additional
--- a/guava/src/com/google/common/io/CharSource.java
+++ b/guava/src/com/google/common/io/CharSource.java
@@ -84,7 +84,7 @@
 @J2ktIncompatible
 @GwtIncompatible
 @ElementTypesAreNonnullByDefault
-public abstract class CharSource {
+public abstract class CharSource implements InputSupplier<Reader> {
 
   /** Constructor for use by subclasses. */
   protected CharSource() {}
@@ -115,6 +115,21 @@
   public abstract Reader openStream() throws IOException;
 
   /**
+   * This method is a temporary method provided for easing migration from suppliers to sources and
+   * sinks.
+   *
+   * @since 15.0
+   * @deprecated This method is only provided for temporary compatibility with the
+   *     {@link InputSupplier} interface and should not be called directly. Use {@link #openStream}
+   *     instead. This method is scheduled for removal in Guava 18.0.
+   */
+  @Override
+  @Deprecated
+  public final Reader getInput() throws IOException {
+    return openStream();
+  }
+
+  /**
    * Opens a new {@link BufferedReader} for reading from this source. This method returns a new,
    * independent reader each time it is called.
    *
--- a/guava/src/com/google/common/io/CharStreams.java
+++ b/guava/src/com/google/common/io/CharStreams.java
@@ -23,9 +23,15 @@
 import java.io.Closeable;
 import java.io.EOFException;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.Reader;
+import java.io.StringReader;
 import java.io.Writer;
 import java.nio.CharBuffer;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 import javax.annotation.CheckForNull;
@@ -59,6 +65,57 @@
   private CharStreams() {}
 
   /**
+   * Returns a factory that will supply instances of {@link StringReader} that
+   * read a string value.
+   *
+   * @param value the string to read
+   * @return the factory
+   * @deprecated Use {@link CharSource#wrap(CharSequence)} instead. This method
+   *     is scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<StringReader> newReaderSupplier(
+      final String value) {
+    return asInputSupplier(CharSource.wrap(value));
+  }
+
+  /**
+   * Returns a factory that will supply instances of {@link InputStreamReader},
+   * using the given {@link InputStream} factory and character set.
+   *
+   * @param in the factory that will be used to open input streams
+   * @param charset the charset used to decode the input stream; see {@link
+   *     Charsets} for helpful predefined constants
+   * @return the factory
+   * @deprecated Use {@link ByteSource#asCharSource(Charset)} instead. This
+   *     method is scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<InputStreamReader> newReaderSupplier(
+      final InputSupplier<? extends InputStream> in, final Charset charset) {
+    return asInputSupplier(
+        ByteStreams.asByteSource(in).asCharSource(charset));
+  }
+
+  /**
+   * Returns a factory that will supply instances of {@link OutputStreamWriter},
+   * using the given {@link OutputStream} factory and character set.
+   *
+   * @param out the factory that will be used to open output streams
+   * @param charset the charset used to encode the output stream; see {@link
+   *     Charsets} for helpful predefined constants
+   * @return the factory
+   * @deprecated Use {@link ByteSink#asCharSink(Charset)} instead. This method
+   *     is scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static OutputSupplier<OutputStreamWriter> newWriterSupplier(
+      final OutputSupplier<? extends OutputStream> out, final Charset charset) {
+    return asOutputSupplier(
+        ByteStreams.asByteSink(out).asCharSink(charset));
+  }
+
+  /**
    * Copies all characters between the {@link Readable} and {@link Appendable} objects. Does not
    * close or flush either object.
    *
@@ -184,6 +241,49 @@
   }
 
   /**
+   * Reads the first line from a {@link Readable} & {@link Closeable} object
+   * supplied by a factory. The line does not include line-termination
+   * characters, but does include other leading and trailing whitespace.
+   *
+   * @param supplier the factory to read from
+   * @return the first line, or null if the reader is empty
+   * @throws IOException if an I/O error occurs
+   * @deprecated Use {@link CharSource#readFirstLine()} instead. This method is
+   *     scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static <R extends Readable & Closeable> String readFirstLine(
+      InputSupplier<R> supplier) throws IOException {
+    return asCharSource(supplier).readFirstLine();
+  }
+
+  /**
+   * Reads all of the lines from a {@link Readable} & {@link Closeable} object
+   * supplied by a factory. The lines do not include line-termination
+   * characters, but do include other leading and trailing whitespace.
+   *
+   * @param supplier the factory to read from
+   * @return a mutable {@link List} containing all the lines
+   * @throws IOException if an I/O error occurs
+   * @deprecated Use {@link CharSource#readLines()} instead, but note that it
+   *     returns an {@code ImmutableList}. This method is scheduled for removal
+   *     in Guava 18.0.
+   */
+  @Deprecated
+  public static <R extends Readable & Closeable> List<String> readLines(
+      InputSupplier<R> supplier) throws IOException {
+    Closer closer = Closer.create();
+    try {
+      R r = closer.register(supplier.getInput());
+      return readLines(r);
+    } catch (Throwable e) {
+      throw closer.rethrow(e);
+    } finally {
+      closer.close();
+    }
+  }
+
+  /**
    * Reads all of the lines from a {@link Readable} object. The lines do not include
    * line-termination characters, but do include other leading and trailing whitespace.
    *
@@ -346,4 +446,103 @@
     }
     return new AppendableWriter(target);
   }
+
+  // TODO(cgdecker): Remove these once Input/OutputSupplier methods are removed
+
+  static Reader asReader(final Readable readable) {
+    checkNotNull(readable);
+    if (readable instanceof Reader) {
+      return (Reader) readable;
+    }
+    return new Reader() {
+      @Override
+      public int read(char[] cbuf, int off, int len) throws IOException {
+        return read(CharBuffer.wrap(cbuf, off, len));
+      }
+
+      @Override
+      public int read(CharBuffer target) throws IOException {
+        return readable.read(target);
+      }
+
+      @Override
+      public void close() throws IOException {
+        if (readable instanceof Closeable) {
+          ((Closeable) readable).close();
+        }
+      }
+    };
+  }
+
+  /**
+   * Returns a view of the given {@code Readable} supplier as a
+   * {@code CharSource}.
+   *
+   * <p>This method is a temporary method provided for easing migration from
+   * suppliers to sources and sinks.
+   *
+   * @since 15.0
+   * @deprecated Convert all {@code InputSupplier<? extends Readable>}
+   *     implementations to extend {@link CharSource} or provide a method for
+   *     viewing the object as a {@code CharSource}. This method is scheduled
+   *     for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static CharSource asCharSource(
+      final InputSupplier<? extends Readable> supplier) {
+    checkNotNull(supplier);
+    return new CharSource() {
+      @Override
+      public Reader openStream() throws IOException {
+        return asReader(supplier.getInput());
+      }
+
+      @Override
+      public String toString() {
+        return "CharStreams.asCharSource(" + supplier + ")";
+      }
+    };
+  }
+
+  /**
+   * Returns a view of the given {@code Appendable} supplier as a
+   * {@code CharSink}.
+   *
+   * <p>This method is a temporary method provided for easing migration from
+   * suppliers to sources and sinks.
+   *
+   * @since 15.0
+   * @deprecated Convert all {@code OutputSupplier<? extends Appendable>}
+   *     implementations to extend {@link CharSink} or provide a method for
+   *     viewing the object as a {@code CharSink}. This method is scheduled
+   *     for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static CharSink asCharSink(
+      final OutputSupplier<? extends Appendable> supplier) {
+    checkNotNull(supplier);
+    return new CharSink() {
+      @Override
+      public Writer openStream() throws IOException {
+        return asWriter(supplier.getOutput());
+      }
+
+      @Override
+      public String toString() {
+        return "CharStreams.asCharSink(" + supplier + ")";
+      }
+    };
+  }
+
+  @SuppressWarnings("unchecked") // used internally where known to be safe
+  static <R extends Reader> InputSupplier<R> asInputSupplier(
+      CharSource source) {
+    return (InputSupplier) checkNotNull(source);
+  }
+
+  @SuppressWarnings("unchecked") // used internally where known to be safe
+  static <W extends Writer> OutputSupplier<W> asOutputSupplier(
+      CharSink sink) {
+    return (OutputSupplier) checkNotNull(sink);
+  }
 }
--- a/guava/src/com/google/common/io/Files.java
+++ b/guava/src/com/google/common/io/Files.java
@@ -226,6 +226,114 @@
   }
 
   /**
+   * Returns a factory that will supply instances of {@link FileInputStream}
+   * that read from a file.
+   *
+   * @param file the file to read from
+   * @return the factory
+   * @deprecated Use {@link #asByteSource(File)}. This method is scheduled for
+   *     removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<FileInputStream> newInputStreamSupplier(
+      final File file) {
+    return ByteStreams.asInputSupplier(asByteSource(file));
+  }
+
+  /**
+   * Returns a factory that will supply instances of {@link FileOutputStream}
+   * that write to a file.
+   *
+   * @param file the file to write to
+   * @return the factory
+   * @deprecated Use {@link #asByteSink(File)}. This method is scheduled for
+   *     removal in Guava 18.0.
+   */
+  @Deprecated
+  public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
+      File file) {
+    return newOutputStreamSupplier(file, false);
+  }
+
+  /**
+   * Returns a factory that will supply instances of {@link FileOutputStream}
+   * that write to or append to a file.
+   *
+   * @param file the file to write to
+   * @param append if true, the encoded characters will be appended to the file;
+   *     otherwise the file is overwritten
+   * @return the factory
+   * @deprecated Use {@link #asByteSink(File, FileWriteMode...)}, passing
+   *     {@link FileWriteMode#APPEND} for append. This method is scheduled for
+   *     removal in Guava 18.0.
+   */
+  @Deprecated
+  public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
+      final File file, final boolean append) {
+    return ByteStreams.asOutputSupplier(asByteSink(file, modes(append)));
+  }
+
+  private static FileWriteMode[] modes(boolean append) {
+    return append
+        ? new FileWriteMode[]{ FileWriteMode.APPEND }
+        : new FileWriteMode[0];
+  }
+
+  /**
+   * Returns a factory that will supply instances of
+   * {@link InputStreamReader} that read a file using the given character set.
+   *
+   * @param file the file to read from
+   * @param charset the charset used to decode the input stream; see {@link
+   *     Charsets} for helpful predefined constants
+   * @return the factory
+   * @deprecated Use {@link #asCharSource(File, Charset)}. This method is
+   *     scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static InputSupplier<InputStreamReader> newReaderSupplier(File file,
+      Charset charset) {
+    return CharStreams.asInputSupplier(asCharSource(file, charset));
+  }
+
+  /**
+   * Returns a factory that will supply instances of {@link OutputStreamWriter}
+   * that write to a file using the given character set.
+   *
+   * @param file the file to write to
+   * @param charset the charset used to encode the output stream; see {@link
+   *     Charsets} for helpful predefined constants
+   * @return the factory
+   * @deprecated Use {@link #asCharSink(File, Charset)}. This method is
+   *     scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static OutputSupplier<OutputStreamWriter> newWriterSupplier(File file,
+      Charset charset) {
+    return newWriterSupplier(file, charset, false);
+  }
+
+  /**
+   * Returns a factory that will supply instances of {@link OutputStreamWriter}
+   * that write to or append to a file using the given character set.
+   *
+   * @param file the file to write to
+   * @param charset the charset used to encode the output stream; see {@link
+   *     Charsets} for helpful predefined constants
+   * @param append if true, the encoded characters will be appended to the file;
+   *     otherwise the file is overwritten
+   * @return the factory
+   * @deprecated Use {@link #asCharSink(File, Charset, FileWriteMode...)},
+   *     passing {@link FileWriteMode#APPEND} for append. This method is
+   *     scheduled for removal in Guava 18.0.
+   */
+  @Deprecated
+  public static OutputSupplier<OutputStreamWriter> newWriterSupplier(File file,
+      Charset charset, boolean append) {
+    return CharStreams.asOutputSupplier(asCharSink(file, charset, modes(append)));
+  }
+
+  /**
    * Reads all bytes from a file into a byte array.
    *
    * <p><b>{@link java.nio.file.Path} equivalent:</b> {@link java.nio.file.Files#readAllBytes}.
--- /dev/null
+++ b/guava/src/com/google/common/io/InputSupplier.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed 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 com.google.common.io;
+
+import java.io.IOException;
+
+/**
+ * A factory for readable streams of bytes or characters.
+ *
+ * @author Chris Nokleberg
+ * @since 1.0
+ * @deprecated For {@code InputSupplier<? extends InputStream>}, use
+ *     {@link ByteSource} instead. For {@code InputSupplier<? extends Reader>},
+ *     use {@link CharSource}. Implementations of {@code InputSupplier} that
+ *     don't fall into one of those categories do not benefit from any of the
+ *     methods in {@code common.io} and should use a different interface. This
+ *     interface is scheduled for removal in December 2015.
+ */
+@Deprecated
+public interface InputSupplier<T> {
+
+  /**
+   * Returns an object that encapsulates a readable resource.
+   * <p>
+   * Like {@link Iterable#iterator}, this method may be called repeatedly to
+   * get independent channels to the same underlying resource.
+   * <p>
+   * Where the channel maintains a position within the resource, moving that
+   * cursor within one channel should not affect the starting position of
+   * channels returned by other calls.
+   */
+  T getInput() throws IOException;
+}
--- /dev/null
+++ b/guava/src/com/google/common/io/OutputSupplier.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed 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 com.google.common.io;
+
+import java.io.IOException;
+
+/**
+ * A factory for writable streams of bytes or characters.
+ *
+ * @author Chris Nokleberg
+ * @since 1.0
+ * @deprecated For {@code OutputSupplier<? extends OutputStream>}, use
+ *     {@link ByteSink} instead. For {@code OutputSupplier<? extends Writer>},
+ *     use {@link CharSink}. Implementations of {@code OutputSupplier} that
+ *     don't fall into one of those categories do not benefit from any of the
+ *     methods in {@code common.io} and should use a different interface. This
+ *     interface is scheduled for removal in December 2015.
+ */
+@Deprecated
+public interface OutputSupplier<T> {
+
+  /**
+   * Returns an object that encapsulates a writable resource.
+   * <p>
+   * Like {@link Iterable#iterator}, this method may be called repeatedly to
+   * get independent channels to the same underlying resource.
+   * <p>
+   * Where the channel maintains a position within the resource, moving that
+   * cursor within one channel should not affect the starting position of
+   * channels returned by other calls.
+   */
+  T getOutput() throws IOException;
+}