Top Deprecated
Guava: Google Core Libraries for Java 32.1.2-jre

Deprecated API


No API in this release is deprecated for removal.

Deprecated Item Summary

SinceDeprecated Item and Description
com.google.common.base.CharMatcher.apply(Character character)

Provided only to satisfy the Predicate interface; use matches instead.

com.google.common.base.CharMatcher.digit()

Many digits are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.invisible()

Most invisible characters are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.javaDigit()

Many digits are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.javaLetter()

Most letters are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.javaLetterOrDigit()

Most letters and digits are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.javaLowerCase()

Some lowercase characters are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.javaUpperCase()

Some uppercase characters are supplementary characters; see the class documentation.

com.google.common.base.CharMatcher.singleWidth()

Many such characters are supplementary characters; see the class documentation.

com.google.common.base.Converter.apply(A
the function argument
a
)

Provided to satisfy the Function interface; use convert instead.

com.google.common.base.Equivalence.test(T
the first input argument
t
,
T
the second input argument
u
)

Provided only to satisfy the BiPredicate interface; use equivalent instead.

com.google.common.base.StandardSystemProperty.JAVA_EXT_DIRS

This property was deprecated in Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are using it, it is probably not doing what you want.

com.google.common.base.Throwables.lazyStackTrace(Throwable throwable)

This method is equivalent to Throwable#getStackTrace() on JDK versions past JDK 8 and on all Android versions. Use Throwable#getStackTrace() directly, or where possible use the java.lang.StackWalker.walk method introduced in JDK 9.

com.google.common.base.Throwables.lazyStackTraceIsLazy()

This method always returns false on JDK versions past JDK 8 and on all Android versions.

Returns:

nothing will ever be returned; this return type is only for your convenience, as illustrated in the example above
com.google.common.base.Throwables.propagate
(Throwable
the Throwable to propagate
throwable
)

Use throw e or throw new RuntimeException(e) directly, or use a combination of throwIfUnchecked and throw new RuntimeException(e). For background on the deprecation, read Why we deprecated Throwables.propagate.

com.google.common.base.Throwables.propagateIfInstanceOf(Throwable throwable, Class<X> declaredType)

Use throwIfInstanceOf, which has the same behavior but rejects null.

com.google.common.base.Throwables.propagateIfPossible(Throwable throwable)

Use throwIfUnchecked, which has the same behavior but rejects null.

com.google.common.cache.LoadingCache.apply(K
the function argument
key
)

Provided to satisfy the Function interface; use get or getUnchecked instead.

com.google.common.collect.ArrayListMultimap.trimToSize()

For a ListMultimap that automatically trims to size, use ImmutableListMultimap. If you need a mutable collection, remove the trimToSize call, or switch to a HashMap<K, ArrayList<V>>.

com.google.common.collect.ArrayTable.remove(Object
row key of mapping to be removed
rowKey
,
Object
column key of mapping to be removed
columnKey
)

Use erase

com.google.common.collect.ComparisonChain.compare(Boolean left, Boolean right)

Use compareFalseFirst; or, if the parameters passed are being either negated or reversed, undo the negation or reversal and use compareTrueFirst.

com.google.common.collect.ComputationException

This exception is no longer thrown by com.google.common. Previously, it was thrown by MapMaker computing maps. When support for computing maps was removed from MapMaker, it was added to CacheBuilder, which throws ExecutionException, UncheckedExecutionException, and ExecutionError. Any code that is still catching ComputationException may need to be updated to catch some of those types instead. (Note that this type, though deprecated, is not planned to be removed from Guava.)

com.google.common.collect.FluentIterable.from(FluentIterable<E> iterable)

instances of FluentIterable don't need to be converted to FluentIterable

com.google.common.collect.ForwardingBlockingDeque<E>

This class has moved to com.google.common.util.concurrent. Please use com.google.common.util.concurrent.ForwardingBlockingDeque instead.

com.google.common.collect.ImmutableBiMap.Builder.buildKeepingLast()

This method does not make sense for bimaps and should not be called.

com.google.common.collect.ImmutableBiMap.forcePut(K
the key with which the specified value is to be associated
key
,
V
the value to be associated with the specified key
value
)

Unsupported operation.

com.google.common.collect.ImmutableBiMapFauxverideShim.toImmutableMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction)

Use ImmutableBiMap#toImmutableBiMap.

com.google.common.collect.ImmutableBiMapFauxverideShim.toImmutableMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction, BinaryOperator<V> mergeFunction)

com.google.common.collect.ImmutableCollection.add(E
element whose presence in this collection is to be ensured
e
)

Unsupported operation.

com.google.common.collect.ImmutableCollection.addAll(Collection<? extends E>
collection containing elements to be added to this collection
newElements
)

Unsupported operation.

com.google.common.collect.ImmutableCollection.remove(Object
element to be removed from this collection, if present
object
)

Unsupported operation.

com.google.common.collect.ImmutableCollection.removeAll(Collection<?>
collection containing elements to be removed from this collection
oldElements
)

Unsupported operation.

com.google.common.collect.ImmutableCollection.removeIf(Predicate<? super E>
a predicate which returns true for elements to be removed
filter
)

Unsupported operation.

com.google.common.collect.ImmutableCollection.retainAll(Collection<?>
collection containing elements to be retained in this collection
elementsToKeep
)

Unsupported operation.

com.google.common.collect.ImmutableList.add(int
index at which the specified element is to be inserted
index
,
E
element to be inserted
element
)

Unsupported operation.

com.google.common.collect.ImmutableList.addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<? extends E>
collection containing elements to be added to this list
newElements
)

Unsupported operation.

com.google.common.collect.ImmutableList.asList()

There is no reason to use this; it always returns this.

com.google.common.collect.ImmutableList.remove(int
the index of the element to be removed
index
)

Unsupported operation.

com.google.common.collect.ImmutableList.replaceAll(UnaryOperator<E>
the operator to apply to each element
operator
)

Unsupported operation.

com.google.common.collect.ImmutableList.set(int
index of the element to replace
index
,
E
element to be stored at the specified position
element
)

Unsupported operation.

com.google.common.collect.ImmutableList.sort(@Nullable Comparator<? super E>
the Comparator used to compare list elements. A null value indicates that the elements' natural ordering should be used
c
)

Unsupported operation.

com.google.common.collect.ImmutableListMultimap.replaceValues(K key, Iterable<? extends V> values)

Unsupported operation.

com.google.common.collect.ImmutableMap.compute(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super @Nullable V, ? extends V>
the remapping function to compute a value
remappingFunction
)

Unsupported operation.

com.google.common.collect.ImmutableMap.computeIfAbsent(K
key with which the specified value is to be associated
key
,
Function<? super K, ? extends V>
the mapping function to compute a value
mappingFunction
)

Unsupported operation.

com.google.common.collect.ImmutableMap.computeIfPresent(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the remapping function to compute a value
remappingFunction
)

Unsupported operation.

com.google.common.collect.ImmutableMap.merge(K
key with which the resulting value is to be associated
key
,
V
the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
value
,
BiFunction<? super V, ? super V, ? extends @Nullable V>
the remapping function to recompute a value if present
function
)

Unsupported operation.

com.google.common.collect.ImmutableMap.put(K
key with which the specified value is to be associated
k
,
V
value to be associated with the specified key
v
)

Unsupported operation.

com.google.common.collect.ImmutableMap.putAll(Map<? extends K, ? extends V>
mappings to be stored in this map
map
)

Unsupported operation.

com.google.common.collect.ImmutableMap.putIfAbsent(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Unsupported operation.

com.google.common.collect.ImmutableMap.remove(Object
key whose mapping is to be removed from the map
o
)

Unsupported operation.

com.google.common.collect.ImmutableMap.remove(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
value
)

Unsupported operation.

com.google.common.collect.ImmutableMap.replace(K
key with which the specified value is associated
key
,
V
value expected to be associated with the specified key
oldValue
,
V
value to be associated with the specified key
newValue
)

Unsupported operation.

com.google.common.collect.ImmutableMap.replace(K
key with which the specified value is associated
key
,
V
value to be associated with the specified key
value
)

Unsupported operation.

com.google.common.collect.ImmutableMap.replaceAll(BiFunction<? super K, ? super V, ? extends V>
the function to apply to each entry
function
)

Unsupported operation.

com.google.common.collect.ImmutableMultimap.put(K key, V value)

Unsupported operation.

com.google.common.collect.ImmutableMultimap.putAll(K key, Iterable<? extends V> values)

Unsupported operation.

com.google.common.collect.ImmutableMultimap.putAll(Multimap<? extends K, ? extends V> multimap)

Unsupported operation.

com.google.common.collect.ImmutableMultimap.replaceValues(K key, Iterable<? extends V> values)

Unsupported operation.

com.google.common.collect.ImmutableMultiset.add(E
the element to add occurrences of; may be null only if explicitly allowed by the implementation
element
,
int
the number of occurrences of the element to add. May be zero, in which case no change will be made.
occurrences
)

Unsupported operation.

com.google.common.collect.ImmutableMultiset.remove(Object
the element to conditionally remove occurrences of
element
,
int
the number of occurrences of the element to remove. May be zero, in which case no change will be made.
occurrences
)

Unsupported operation.

com.google.common.collect.ImmutableMultiset.setCount(E
the element to add or remove occurrences of; may be null only if explicitly allowed by the implementation
element
,
int
the desired count of the element in this multiset
count
)

Unsupported operation.

com.google.common.collect.ImmutableMultiset.setCount(E
the element to conditionally set the count of; may be null only if explicitly allowed by the implementation
element
,
int
the expected present count of the element in this multiset
oldCount
,
int
the desired count of the element in this multiset
newCount
)

Unsupported operation.

com.google.common.collect.ImmutableRangeMap.merge(Range<K> range, V value, BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction)

Unsupported operation.

com.google.common.collect.ImmutableRangeMap.put(Range<K> range, V value)

Unsupported operation.

com.google.common.collect.ImmutableRangeMap.putAll(RangeMap<K, ? extends V> rangeMap)

Unsupported operation.

com.google.common.collect.ImmutableRangeMap.putCoalescing(Range<K> range, V value)

Unsupported operation.

com.google.common.collect.ImmutableSetMultimap.replaceValues(K key, Iterable<? extends V> values)

Unsupported operation.

com.google.common.collect.ImmutableSortedMap.Builder.buildKeepingLast()

This method is not currently implemented, and may never be.

com.google.common.collect.ImmutableSortedMap.Builder.orderEntriesByValue(Comparator<? super V> valueComparator)

Unsupported by ImmutableSortedMap.Builder.

com.google.common.collect.ImmutableSortedMapFauxverideShim.builderWithExpectedSize(int expectedSize)

Not supported for ImmutableSortedMap.

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the mapping's key
k1
,
V
the mapping's value
v1
)

Pass a key of type Comparable to use ImmutableSortedMap#of(Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
,
K
the fifth mapping's key
k5
,
V
the fifth mapping's value
v5
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
,
K
the fifth mapping's key
k5
,
V
the fifth mapping's value
v5
,
K
the sixth mapping's key
k6
,
V
the sixth mapping's value
v6
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
,
K
the fifth mapping's key
k5
,
V
the fifth mapping's value
v5
,
K
the sixth mapping's key
k6
,
V
the sixth mapping's value
v6
,
K
the seventh mapping's key
k7
,
V
the seventh mapping's value
v7
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
,
K
the fifth mapping's key
k5
,
V
the fifth mapping's value
v5
,
K
the sixth mapping's key
k6
,
V
the sixth mapping's value
v6
,
K
the seventh mapping's key
k7
,
V
the seventh mapping's value
v7
,
K
the eighth mapping's key
k8
,
V
the eighth mapping's value
v8
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
,
K
the fifth mapping's key
k5
,
V
the fifth mapping's value
v5
,
K
the sixth mapping's key
k6
,
V
the sixth mapping's value
v6
,
K
the seventh mapping's key
k7
,
V
the seventh mapping's value
v7
,
K
the eighth mapping's key
k8
,
V
the eighth mapping's value
v8
,
K
the ninth mapping's key
k9
,
V
the ninth mapping's value
v9
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.of(K
the first mapping's key
k1
,
V
the first mapping's value
v1
,
K
the second mapping's key
k2
,
V
the second mapping's value
v2
,
K
the third mapping's key
k3
,
V
the third mapping's value
v3
,
K
the fourth mapping's key
k4
,
V
the fourth mapping's value
v4
,
K
the fifth mapping's key
k5
,
V
the fifth mapping's value
v5
,
K
the sixth mapping's key
k6
,
V
the sixth mapping's value
v6
,
K
the seventh mapping's key
k7
,
V
the seventh mapping's value
v7
,
K
the eighth mapping's key
k8
,
V
the eighth mapping's value
v8
,
K
the ninth mapping's key
k9
,
V
the ninth mapping's value
v9
,
K
the tenth mapping's key
k10
,
V
the tenth mapping's value
v10
)

Pass keys of type Comparable to use ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).

com.google.common.collect.ImmutableSortedMapFauxverideShim.ofEntries(Map.Entry<? extends K, ? extends V>...
Map.Entrys containing the keys and values from which the map is populated
entries
)

Use ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...)).

com.google.common.collect.ImmutableSortedMapFauxverideShim.toImmutableMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction, BinaryOperator<V> mergeFunction)

Use ImmutableSortedMap#toImmutableSortedMap.

com.google.common.collect.ImmutableSortedSetFauxverideShim.builderWithExpectedSize(int expectedSize)

Not supported by ImmutableSortedSet.

com.google.common.collect.ImmutableSortedSetFauxverideShim.of(E
the single element
element
)

Pass a parameter of type Comparable to use ImmutableSortedSet#of(Comparable).

com.google.common.collect.ImmutableSortedSetFauxverideShim.of(E
the first element
e1
,
E
the second element
e2
)

Pass the parameters of type Comparable to use ImmutableSortedSet#of(Comparable, Comparable).

com.google.common.collect.ImmutableSortedSetFauxverideShim.of(E
the first element
e1
,
E
the second element
e2
,
E
the third element
e3
)

Pass the parameters of type Comparable to use ImmutableSortedSet#of(Comparable, Comparable, Comparable).

com.google.common.collect.ImmutableSortedSetFauxverideShim.of(E
the first element
e1
,
E
the second element
e2
,
E
the third element
e3
,
E
the fourth element
e4
)

Pass the parameters of type Comparable to use ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable).

com.google.common.collect.ImmutableSortedSetFauxverideShim.of(E
the first element
e1
,
E
the second element
e2
,
E
the third element
e3
,
E
the fourth element
e4
,
E
the fifth element
e5
)

Pass the parameters of type Comparable to use ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable).

com.google.common.collect.ImmutableSortedSetFauxverideShim.of(E
the first element
e1
,
E
the second element
e2
,
E
the third element
e3
,
E
the fourth element
e4
,
E
the fifth element
e5
,
E
the sixth element
e6
,
E...
the seventh element
remaining
)

Pass the parameters of type Comparable to use ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable, Comparable, Comparable...).

com.google.common.collect.ImmutableTable.put(R
row key that the value should be associated with
rowKey
,
C
column key that the value should be associated with
columnKey
,
V
value to be associated with the specified keys
value
)

Unsupported operation.

com.google.common.collect.ImmutableTable.putAll(Table<? extends R, ? extends C, ? extends V>
the table to add to this table
table
)

Unsupported operation.

com.google.common.collect.ImmutableTable.remove(Object
row key of mapping to be removed
rowKey
,
Object
column key of mapping to be removed
columnKey
)

Unsupported operation.

com.google.common.collect.Ordering.binarySearch(List<? extends T>
the list to be searched
sortedList
,
T
the key to be searched for
key
)

Use Collections#binarySearch(List, Object, Comparator) directly.

com.google.common.collect.Ordering.from(Ordering<T> ordering)

no need to use this

com.google.common.collect.Range.apply(C input)

Provided only to satisfy the Predicate interface; use contains instead.

com.google.common.collect.Sets.SetView.add(E
element to be added to this set
e
)

Unsupported operation.

com.google.common.collect.Sets.SetView.addAll(Collection<? extends E>
collection containing elements to be added to this set
newElements
)

Unsupported operation.

com.google.common.collect.Sets.SetView.remove(Object
object to be removed from this set, if present
object
)

Unsupported operation.

com.google.common.collect.Sets.SetView.removeAll(Collection<?>
collection containing elements to be removed from this set
oldElements
)

Unsupported operation.

com.google.common.collect.Sets.SetView.removeIf(Predicate<? super E>
a predicate which returns true for elements to be removed
filter
)

Unsupported operation.

com.google.common.collect.Sets.SetView.retainAll(Collection<?>
collection containing elements to be retained in this set
elementsToKeep
)

Unsupported operation.

Returns:

the set backed by the map
com.google.common.collect.Sets.newSetFromMap
(Map<E, Boolean>
the backing map
map
)

Use Collections#newSetFromMap instead.

com.google.common.collect.Streams.stream(Collection<T> collection)

There is no reason to use this; just invoke collection.stream() directly.

com.google.common.collect.TreeBasedTable.columnComparator()

Store the Comparator alongside the Table. Or, if you know that the Table contains at least one value, you can retrieve the Comparator with: ((SortedMap<C, V>) table.rowMap().values().iterator().next()).comparator();.

com.google.common.collect.TreeBasedTable.rowComparator()

Use table.rowKeySet().comparator() instead.

com.google.common.collect.TreeMultimap.keyComparator()

Use ((NavigableSet<K>) multimap.keySet()).comparator() instead.

com.google.common.collect.TreeTraverser<T>

Use com.google.common.graph.Traverser instead. All instance methods have their equivalent on the result of Traverser.forTree(tree) where tree implements SuccessorsFunction, which has a similar API as children or can be the same lambda function as passed into using(Function).

This class is scheduled to be removed in October 2019.

com.google.common.collect.TreeTraverser.using(final Function<T, ? extends Iterable<T>> nodeToChildrenFunction)

Use com.google.common.graph.Traverser#forTree instead. If you are using a lambda, these methods have exactly the same signature.

com.google.common.collect.UnmodifiableListIterator.add(E
the element to insert
e
)

Unsupported operation.

com.google.common.collect.UnmodifiableListIterator.set(E
the element with which to replace the last element returned by next or previous
e
)

Unsupported operation.

com.google.common.hash.BloomFilter.apply(T input)

Provided only to satisfy the Predicate interface; use mightContain instead.

com.google.common.hash.Hasher.hashCode()

This returns Object#hashCode(); you almost certainly mean to call hash().asInt().

com.google.common.hash.Hashing.md5()

If you must interoperate with a system that requires MD5, then use this method, despite its deprecation. But if you can choose your hash function, avoid MD5, which is neither fast nor secure. As of January 2017, we suggest:

com.google.common.hash.Hashing.murmur3_32(int seed)

This implementation produces incorrect hash values from the HashFunction#hashString method if the string contains non-BMP characters. Use murmur3_32_fixed(int) instead.

com.google.common.hash.Hashing.murmur3_32()

This implementation produces incorrect hash values from the HashFunction#hashString method if the string contains non-BMP characters. Use murmur3_32_fixed() instead.

com.google.common.hash.Hashing.sha1()

If you must interoperate with a system that requires SHA-1, then use this method, despite its deprecation. But if you can choose your hash function, avoid SHA-1, which is neither fast nor secure. As of January 2017, we suggest:

com.google.common.io.ByteArrayDataOutput.writeBytes(String
the string of bytes to be written.
s
)

This method is dangerous as it discards the high byte of every character. For UTF-8, use write(s.getBytes(StandardCharsets.UTF_8)).

com.google.common.io.Files.append(CharSequence
the character sequence to append
from
,
File
the destination file
to
,
Charset
the charset used to encode the output stream; see StandardCharsets for helpful predefined constants
charset
)

Prefer asCharSink(to, charset, FileWriteMode.APPEND).write(from). This method is scheduled to be removed in October 2019.

com.google.common.io.Files.copy(File
the source file
from
,
Charset
the charset used to decode the input stream; see StandardCharsets for helpful predefined constants
charset
,
Appendable
the appendable object
to
)

Prefer asCharSource(from, charset).copyTo(to).

Returns:

the newly-created directory
com.google.common.io.Files.createTempDir
()

For Android users, see the Data and File Storage overview to select an appropriate temporary directory (perhaps context.getCacheDir()), and create your own directory under that. (For example, you might use new File(context.getCacheDir(), "directoryname").mkdir(), or, if you need an arbitrary number of temporary directories, you might have to generate multiple directory names in a loop until mkdir() returns true.) For developers on Java 7 or later, use java.nio.file.Files#createTempDirectory, transforming it to a File using toFile() if needed. To restrict permissions as this method does, pass PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------")) to your call to createTempDirectory.

Returns:

the HashCode of all of the bytes in the file
com.google.common.io.Files.hash
(File
the file to read
file
,
HashFunction
the hash function to use to hash the data
hashFunction
)

Prefer asByteSource(file).hash(hashFunction).

Returns:

the result of the byte processor
com.google.common.io.Files.readBytes
(File
the file to read
file
,
ByteProcessor<T>
the object to which the bytes of the file are passed.
processor
)

Prefer asByteSource(file).read(processor).

Returns:

the first line, or null if the file is empty
com.google.common.io.Files.readFirstLine
(File
the file to read from
file
,
Charset
the charset used to decode the input stream; see StandardCharsets for helpful predefined constants
charset
)

Prefer asCharSource(file, charset).readFirstLine().

Returns:

the output of processing the lines
com.google.common.io.Files.readLines
(File
the file to read from
file
,
Charset
the charset used to decode the input stream; see StandardCharsets for helpful predefined constants
charset
,
LineProcessor<T>
the LineProcessor to use to handle the lines
callback
)

Prefer asCharSource(file, charset).readLines(callback).

Returns:

a string containing all the characters from the file
com.google.common.io.Files.toString
(File
the file to read from
file
,
Charset
the charset used to decode the input stream; see StandardCharsets for helpful predefined constants
charset
)

Prefer asCharSource(file, charset).read().

com.google.common.io.Files.write(CharSequence
the character sequence to write
from
,
File
the destination file
to
,
Charset
the charset used to encode the output stream; see StandardCharsets for helpful predefined constants
charset
)

Prefer asCharSink(to, charset).write(from).

com.google.common.io.LittleEndianDataOutputStream.writeBytes(String
the string of bytes to be written.
s
)

The semantics of writeBytes(String s) are considered dangerous. Please use writeUTF(String s), writeChars(String s) or another write method instead.

com.google.common.math.DoubleMath.mean(double...
a nonempty series of values
values
)

Use Stats#meanOf instead, noting the less strict handling of non-finite values.

com.google.common.math.DoubleMath.mean(int...
a nonempty series of values
values
)

Use Stats#meanOf instead, noting the less strict handling of non-finite values.

com.google.common.math.DoubleMath.mean(long...
a nonempty series of values, which will be converted to double values (this may cause loss of precision for longs of magnitude over 2^53 (slightly over 9e15))
values
)

Use Stats#meanOf instead, noting the less strict handling of non-finite values.

com.google.common.math.DoubleMath.mean(Iterable<? extends Number>
a nonempty series of values, which will be converted to double values (this may cause loss of precision)
values
)

Use Stats#meanOf instead, noting the less strict handling of non-finite values.

com.google.common.math.DoubleMath.mean(Iterator<? extends Number>
a nonempty series of values, which will be converted to double values (this may cause loss of precision)
values
)

Use Stats#meanOf instead, noting the less strict handling of non-finite values.

com.google.common.reflect.ImmutableTypeToInstanceMap.put(TypeToken<? extends B>
key with which the specified value is to be associated
key
,
B
value to be associated with the specified key
value
)

unsupported operation

com.google.common.reflect.ImmutableTypeToInstanceMap.putAll(Map<? extends TypeToken<? extends B>, ? extends B>
mappings to be stored in this map
map
)

unsupported operation

com.google.common.reflect.MutableTypeToInstanceMap.put(TypeToken<? extends @NonNull B>
key with which the specified value is to be associated
key
,
B
value to be associated with the specified key
value
)

unsupported operation

com.google.common.reflect.MutableTypeToInstanceMap.putAll(Map<? extends TypeToken<? extends @NonNull B>, ? extends B>
mappings to be stored in this map
map
)

unsupported operation

com.google.common.util.concurrent.ClosingFuture.eventuallyClosing(ListenableFuture<C>
the future to create the ClosingFuture from. For discussion of the future's result type C, see DeferredCloser#eventuallyClose(Object, Executor).
future
,
final Executor
the future's result will be closed on this executor
closingExecutor
)

Creating Futures of closeable types is dangerous in general because the underlying value may never be closed if the Future is canceled after its operation begins. Consider replacing code that creates ListenableFutures of closeable types, including those that pass them to this method, with submit(ClosingCallable, Executor) in order to ensure that resources do not leak. Or, to start a pipeline with a ListenableFuture that doesn't create values that should be closed, use ClosingFuture#from.