2003-05-27 Michael Koch <konqueror@gmx.de>
* java/net/URLConnection.java (getHeaderFieldInt): Merged with classpath. From-SVN: r67184
This commit is contained in:
parent
c414a2c3c9
commit
5191f392bb
2 changed files with 17 additions and 8 deletions
|
@ -322,25 +322,29 @@ public abstract class URLConnection
|
|||
* is not present or cannot be parsed as an integer, the default value
|
||||
* will be returned.
|
||||
*
|
||||
* @param name The name of the header field
|
||||
* @param val The default value
|
||||
* @param name The header field key to lookup
|
||||
* @param defaultValue The defaule value if the header field is not found
|
||||
* or can't be parsed.
|
||||
*
|
||||
* @return The value of the header field or the default value if the field
|
||||
* is missing or malformed
|
||||
*/
|
||||
public int getHeaderFieldInt(String name, int val)
|
||||
public int getHeaderFieldInt(String name, int defaultValue)
|
||||
{
|
||||
String str = getHeaderField(name);
|
||||
int result = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
if (str != null)
|
||||
val = Integer.parseInt(str);
|
||||
result = Integer.parseInt (str);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
; // Do nothing; val is the default.
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
; // Do nothing; defaultValue is the default.
|
||||
}
|
||||
return val;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue