32
32
import com .google .common .hash .HashCode ;
33
33
import com .google .common .hash .HashFunction ;
34
34
import com .google .errorprone .annotations .CanIgnoreReturnValue ;
35
+ import com .google .errorprone .annotations .InlineMe ;
35
36
import java .io .BufferedReader ;
36
37
import java .io .BufferedWriter ;
37
38
import java .io .File ;
@@ -85,7 +86,6 @@ private Files() {}
85
86
* helpful predefined constants
86
87
* @return the buffered reader
87
88
*/
88
- @ Beta
89
89
public static BufferedReader newReader (File file , Charset charset ) throws FileNotFoundException {
90
90
checkNotNull (file );
91
91
checkNotNull (charset );
@@ -104,7 +104,6 @@ public static BufferedReader newReader(File file, Charset charset) throws FileNo
104
104
* helpful predefined constants
105
105
* @return the buffered writer
106
106
*/
107
- @ Beta
108
107
public static BufferedWriter newWriter (File file , Charset charset ) throws FileNotFoundException {
109
108
checkNotNull (file );
110
109
checkNotNull (charset );
@@ -235,7 +234,6 @@ public static CharSink asCharSink(File file, Charset charset, FileWriteMode... m
235
234
* (2^31 - 1)
236
235
* @throws IOException if an I/O error occurs
237
236
*/
238
- @ Beta
239
237
public static byte [] toByteArray (File file ) throws IOException {
240
238
return asByteSource (file ).read ();
241
239
}
@@ -248,11 +246,12 @@ public static byte[] toByteArray(File file) throws IOException {
248
246
* helpful predefined constants
249
247
* @return a string containing all the characters from the file
250
248
* @throws IOException if an I/O error occurs
251
- * @deprecated Prefer {@code asCharSource(file, charset).read()}. This method is scheduled to be
252
- * removed in October 2019.
249
+ * @deprecated Prefer {@code asCharSource(file, charset).read()}.
253
250
*/
254
- @ Beta
255
251
@ Deprecated
252
+ @ InlineMe (
253
+ replacement = "Files.asCharSource(file, charset).read()" ,
254
+ imports = "com.google.common.io.Files" )
256
255
public static String toString (File file , Charset charset ) throws IOException {
257
256
return asCharSource (file , charset ).read ();
258
257
}
@@ -267,7 +266,6 @@ public static String toString(File file, Charset charset) throws IOException {
267
266
* @param to the destination file
268
267
* @throws IOException if an I/O error occurs
269
268
*/
270
- @ Beta
271
269
public static void write (byte [] from , File to ) throws IOException {
272
270
asByteSink (to ).write (from );
273
271
}
@@ -280,11 +278,12 @@ public static void write(byte[] from, File to) throws IOException {
280
278
* @param charset the charset used to encode the output stream; see {@link StandardCharsets} for
281
279
* helpful predefined constants
282
280
* @throws IOException if an I/O error occurs
283
- * @deprecated Prefer {@code asCharSink(to, charset).write(from)}. This method is scheduled to be
284
- * removed in October 2019.
281
+ * @deprecated Prefer {@code asCharSink(to, charset).write(from)}.
285
282
*/
286
- @ Beta
287
283
@ Deprecated
284
+ @ InlineMe (
285
+ replacement = "Files.asCharSink(to, charset).write(from)" ,
286
+ imports = "com.google.common.io.Files" )
288
287
public static void write (CharSequence from , File to , Charset charset ) throws IOException {
289
288
asCharSink (to , charset ).write (from );
290
289
}
@@ -299,7 +298,6 @@ public static void write(CharSequence from, File to, Charset charset) throws IOE
299
298
* @param to the output stream
300
299
* @throws IOException if an I/O error occurs
301
300
*/
302
- @ Beta
303
301
public static void copy (File from , OutputStream to ) throws IOException {
304
302
asByteSource (from ).copyTo (to );
305
303
}
@@ -323,7 +321,6 @@ public static void copy(File from, OutputStream to) throws IOException {
323
321
* @throws IOException if an I/O error occurs
324
322
* @throws IllegalArgumentException if {@code from.equals(to)}
325
323
*/
326
- @ Beta
327
324
public static void copy (File from , File to ) throws IOException {
328
325
checkArgument (!from .equals (to ), "Source %s and destination %s must be different" , from , to );
329
326
asByteSource (from ).copyTo (asByteSink (to ));
@@ -337,11 +334,12 @@ public static void copy(File from, File to) throws IOException {
337
334
* helpful predefined constants
338
335
* @param to the appendable object
339
336
* @throws IOException if an I/O error occurs
340
- * @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}. This method is scheduled to
341
- * be removed in October 2019.
337
+ * @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}.
342
338
*/
343
- @ Beta
344
339
@ Deprecated
340
+ @ InlineMe (
341
+ replacement = "Files.asCharSource(from, charset).copyTo(to)" ,
342
+ imports = "com.google.common.io.Files" )
345
343
public
346
344
static void copy (File from , Charset charset , Appendable to ) throws IOException {
347
345
asCharSource (from , charset ).copyTo (to );
@@ -358,8 +356,10 @@ static void copy(File from, Charset charset, Appendable to) throws IOException {
358
356
* @deprecated Prefer {@code asCharSink(to, charset, FileWriteMode.APPEND).write(from)}. This
359
357
* method is scheduled to be removed in October 2019.
360
358
*/
361
- @ Beta
362
359
@ Deprecated
360
+ @ InlineMe (
361
+ replacement = "Files.asCharSink(to, charset, FileWriteMode.APPEND).write(from)" ,
362
+ imports = {"com.google.common.io.FileWriteMode" , "com.google.common.io.Files" })
363
363
public
364
364
static void append (CharSequence from , File to , Charset charset ) throws IOException {
365
365
asCharSink (to , charset , FileWriteMode .APPEND ).write (from );
@@ -370,7 +370,6 @@ static void append(CharSequence from, File to, Charset charset) throws IOExcepti
370
370
*
371
371
* @throws IOException if an I/O error occurs
372
372
*/
373
- @ Beta
374
373
public static boolean equal (File file1 , File file2 ) throws IOException {
375
374
checkNotNull (file1 );
376
375
checkNotNull (file2 );
@@ -452,7 +451,6 @@ public static File createTempDir() {
452
451
* @param file the file to create or update
453
452
* @throws IOException if an I/O error occurs
454
453
*/
455
- @ Beta
456
454
@ SuppressWarnings ("GoodTime" ) // reading system time without TimeSource
457
455
public static void touch (File file ) throws IOException {
458
456
checkNotNull (file );
@@ -470,7 +468,6 @@ public static void touch(File file) throws IOException {
470
468
* directories of the specified file could not be created.
471
469
* @since 4.0
472
470
*/
473
- @ Beta
474
471
public static void createParentDirs (File file ) throws IOException {
475
472
checkNotNull (file );
476
473
File parent = file .getCanonicalFile ().getParentFile ();
@@ -501,7 +498,6 @@ public static void createParentDirs(File file) throws IOException {
501
498
* @throws IOException if an I/O error occurs
502
499
* @throws IllegalArgumentException if {@code from.equals(to)}
503
500
*/
504
- @ Beta
505
501
public static void move (File from , File to ) throws IOException {
506
502
checkNotNull (from );
507
503
checkNotNull (to );
@@ -527,11 +523,12 @@ public static void move(File from, File to) throws IOException {
527
523
* helpful predefined constants
528
524
* @return the first line, or null if the file is empty
529
525
* @throws IOException if an I/O error occurs
530
- * @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}. This method is
531
- * scheduled to be removed in October 2019.
526
+ * @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}.
532
527
*/
533
- @ Beta
534
528
@ Deprecated
529
+ @ InlineMe (
530
+ replacement = "Files.asCharSource(file, charset).readFirstLine()" ,
531
+ imports = "com.google.common.io.Files" )
535
532
@ CheckForNull
536
533
public
537
534
static String readFirstLine (File file , Charset charset ) throws IOException {
@@ -554,7 +551,6 @@ static String readFirstLine(File file, Charset charset) throws IOException {
554
551
* @return a mutable {@link List} containing all the lines
555
552
* @throws IOException if an I/O error occurs
556
553
*/
557
- @ Beta
558
554
public static List <String > readLines (File file , Charset charset ) throws IOException {
559
555
// don't use asCharSource(file, charset).readLines() because that returns
560
556
// an immutable list, which would change the behavior of this method
@@ -586,11 +582,12 @@ public List<String> getResult() {
586
582
* @param callback the {@link LineProcessor} to use to handle the lines
587
583
* @return the output of processing the lines
588
584
* @throws IOException if an I/O error occurs
589
- * @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}. This method is
590
- * scheduled to be removed in October 2019.
585
+ * @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}.
591
586
*/
592
- @ Beta
593
587
@ Deprecated
588
+ @ InlineMe (
589
+ replacement = "Files.asCharSource(file, charset).readLines(callback)" ,
590
+ imports = "com.google.common.io.Files" )
594
591
@ CanIgnoreReturnValue // some processors won't return a useful result
595
592
@ ParametricNullness
596
593
public
@@ -608,11 +605,12 @@ public List<String> getResult() {
608
605
* @param processor the object to which the bytes of the file are passed.
609
606
* @return the result of the byte processor
610
607
* @throws IOException if an I/O error occurs
611
- * @deprecated Prefer {@code asByteSource(file).read(processor)}. This method is scheduled to be
612
- * removed in October 2019.
608
+ * @deprecated Prefer {@code asByteSource(file).read(processor)}.
613
609
*/
614
- @ Beta
615
610
@ Deprecated
611
+ @ InlineMe (
612
+ replacement = "Files.asByteSource(file).read(processor)" ,
613
+ imports = "com.google.common.io.Files" )
616
614
@ CanIgnoreReturnValue // some processors won't return a useful result
617
615
@ ParametricNullness
618
616
public
@@ -629,11 +627,12 @@ public List<String> getResult() {
629
627
* @return the {@link HashCode} of all of the bytes in the file
630
628
* @throws IOException if an I/O error occurs
631
629
* @since 12.0
632
- * @deprecated Prefer {@code asByteSource(file).hash(hashFunction)}. This method is scheduled to
633
- * be removed in October 2019.
630
+ * @deprecated Prefer {@code asByteSource(file).hash(hashFunction)}.
634
631
*/
635
- @ Beta
636
632
@ Deprecated
633
+ @ InlineMe (
634
+ replacement = "Files.asByteSource(file).hash(hashFunction)" ,
635
+ imports = "com.google.common.io.Files" )
637
636
public
638
637
static HashCode hash (File file , HashFunction hashFunction ) throws IOException {
639
638
return asByteSource (file ).hash (hashFunction );
@@ -654,7 +653,6 @@ static HashCode hash(File file, HashFunction hashFunction) throws IOException {
654
653
* @see FileChannel#map(MapMode, long, long)
655
654
* @since 2.0
656
655
*/
657
- @ Beta
658
656
public static MappedByteBuffer map (File file ) throws IOException {
659
657
checkNotNull (file );
660
658
return map (file , MapMode .READ_ONLY );
@@ -677,7 +675,6 @@ public static MappedByteBuffer map(File file) throws IOException {
677
675
* @see FileChannel#map(MapMode, long, long)
678
676
* @since 2.0
679
677
*/
680
- @ Beta
681
678
public static MappedByteBuffer map (File file , MapMode mode ) throws IOException {
682
679
return mapInternal (file , mode , -1 );
683
680
}
@@ -701,7 +698,6 @@ public static MappedByteBuffer map(File file, MapMode mode) throws IOException {
701
698
* @see FileChannel#map(MapMode, long, long)
702
699
* @since 2.0
703
700
*/
704
- @ Beta
705
701
public static MappedByteBuffer map (File file , MapMode mode , long size ) throws IOException {
706
702
checkArgument (size >= 0 , "size (%s) may not be negative" , size );
707
703
return mapInternal (file , mode , size );
@@ -745,7 +741,6 @@ private static MappedByteBuffer mapInternal(File file, MapMode mode, long size)
745
741
*
746
742
* @since 11.0
747
743
*/
748
- @ Beta
749
744
public static String simplifyPath (String pathname ) {
750
745
checkNotNull (pathname );
751
746
if (pathname .length () == 0 ) {
@@ -806,7 +801,6 @@ public static String simplifyPath(String pathname) {
806
801
*
807
802
* @since 11.0
808
803
*/
809
- @ Beta
810
804
public static String getFileExtension (String fullName ) {
811
805
checkNotNull (fullName );
812
806
String fileName = new File (fullName ).getName ();
@@ -824,7 +818,6 @@ public static String getFileExtension(String fullName) {
824
818
* @return The file name without its path or extension.
825
819
* @since 14.0
826
820
*/
827
- @ Beta
828
821
public static String getNameWithoutExtension (String file ) {
829
822
checkNotNull (file );
830
823
String fileName = new File (file ).getName ();
@@ -880,7 +873,6 @@ public Iterable<File> successors(File file) {
880
873
*
881
874
* @since 15.0
882
875
*/
883
- @ Beta
884
876
public static Predicate <File > isDirectory () {
885
877
return FilePredicate .IS_DIRECTORY ;
886
878
}
@@ -890,7 +882,6 @@ public static Predicate<File> isDirectory() {
890
882
*
891
883
* @since 15.0
892
884
*/
893
- @ Beta
894
885
public static Predicate <File > isFile () {
895
886
return FilePredicate .IS_FILE ;
896
887
}
0 commit comments