你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

UnexpectedLengthException Class

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • java.lang.RuntimeException
          • java.lang.IllegalStateException
            • com.azure.core.exception.UnexpectedLengthException

public final class UnexpectedLengthException
extends IllegalStateException

The UnexpectedLengthException represents an exception thrown when the specified input length doesn't match the actual data length.

This exception is typically thrown when the number of bytes read from an input source does not match the expected number of bytes. This could occur when reading data from a file or a network connection.

This class also provides methods to get the number of bytes read from the input and the number of bytes that were expected to be read from the input.

Constructor Summary

Constructor Description
UnexpectedLengthException(String message, long bytesRead, long bytesExpected)

Constructor of the UnexpectedLengthException.

Method Summary

Modifier and Type Method and Description
long getBytesExpected()

Gets the number of bytes that were expected to be read from the input.

long getBytesRead()

Gets the number of bytes read from the input.

Methods inherited from java.lang.Object

Methods inherited from java.lang.Throwable

Constructor Details

UnexpectedLengthException

public UnexpectedLengthException(String message, long bytesRead, long bytesExpected)

Constructor of the UnexpectedLengthException.

Parameters:

message - The message for the exception.
bytesRead - The number of bytes read from resource.
bytesExpected - The number of bytes expected from the receiver.

Method Details

getBytesExpected

public long getBytesExpected()

Gets the number of bytes that were expected to be read from the input.

Returns:

the number of bytes that were expected to be read from the input

getBytesRead

public long getBytesRead()

Gets the number of bytes read from the input.

Returns:

the number of bytes read from the input

Applies to