Package ucar.httpservices
Class HTTPUtil
- java.lang.Object
-
- ucar.httpservices.HTTPUtil
-
public abstract class HTTPUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description HTTPUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
abspath(String path)
Convert path to add a leading '/'; assumes canonical.static String
canonicalpath(String path)
Convert path to use '/' consistently and to remove any trailing '/'static void
canonicalpath(StringBuilder s)
static String
canonjoin(String prefix, String suffix)
Join two string together to form proper path WITHOUT trailing slashstatic File
fillTempFile(String base, String content)
static boolean
hasDriveLetter(String path)
protected static boolean
hasDriveLetter(StringBuilder path)
static boolean
isAbsolutePath(String path)
protected static Map<ucar.httpservices.HTTPSession.Prop,Object>
merge(Map<ucar.httpservices.HTTPSession.Prop,Object> globalsettings, Map<ucar.httpservices.HTTPSession.Prop,Object> localsettings)
static String
nullify(String s)
Convert a zero-length string to nullstatic URI
parseToURI(String u)
Convert a uri string to an instance of java.net.URI.static byte[]
readbinaryfile(File f)
static byte[]
readbinaryfile(InputStream stream)
static String
readtextfile(InputStream stream)
static String
readtextfile(Reader rdr)
static String
relpath(String path)
Convert path to remove any leading '/' or drive letter assumes canonical.static void
writebinaryfile(byte[] content, File dst)
-
-
-
Field Detail
-
UTF8
public static final Charset UTF8
-
ASCII
public static final Charset ASCII
-
LOWERCASE
public static final String LOWERCASE
- See Also:
- Constant Field Values
-
UPPERCASE
public static final String UPPERCASE
- See Also:
- Constant Field Values
-
DRIVELETTERS
public static final String DRIVELETTERS
- See Also:
- Constant Field Values
-
-
Method Detail
-
readbinaryfile
public static byte[] readbinaryfile(File f) throws IOException
- Throws:
IOException
-
readbinaryfile
public static byte[] readbinaryfile(InputStream stream) throws IOException
- Throws:
IOException
-
fillTempFile
public static File fillTempFile(String base, String content) throws IOException
- Throws:
IOException
-
parseToURI
public static URI parseToURI(String u) throws URISyntaxException
Convert a uri string to an instance of java.net.URI. The critical thing is that this procedure can handle backslash escaped uris as well as %xx escaped uris.- Parameters:
u
- the uri to convert- Returns:
- The URI corresponding to u.
- Throws:
URISyntaxException
-
merge
protected static Map<ucar.httpservices.HTTPSession.Prop,Object> merge(Map<ucar.httpservices.HTTPSession.Prop,Object> globalsettings, Map<ucar.httpservices.HTTPSession.Prop,Object> localsettings)
-
nullify
public static String nullify(String s)
Convert a zero-length string to null- Parameters:
s
- the string to check for length- Returns:
- null if s.length() == 0, s otherwise
-
canonjoin
public static String canonjoin(String prefix, String suffix)
Join two string together to form proper path WITHOUT trailing slash
-
canonicalpath
public static String canonicalpath(String path)
Convert path to use '/' consistently and to remove any trailing '/'- Parameters:
path
- convert this path- Returns:
- canonicalized version
-
canonicalpath
public static void canonicalpath(StringBuilder s)
-
relpath
public static String relpath(String path)
Convert path to remove any leading '/' or drive letter assumes canonical.- Parameters:
path
- convert this path- Returns:
- relatived version
-
hasDriveLetter
public static boolean hasDriveLetter(String path)
- Parameters:
path
- to test- Returns:
- true if path appears to start with Windows drive letter
-
hasDriveLetter
protected static boolean hasDriveLetter(StringBuilder path)
-
isAbsolutePath
public static boolean isAbsolutePath(String path)
- Parameters:
path
- to test- Returns:
- true if path is absolute
-
abspath
public static String abspath(String path)
Convert path to add a leading '/'; assumes canonical.- Parameters:
path
- convert this path- Returns:
- absolute version
-
readtextfile
public static String readtextfile(InputStream stream) throws IOException
- Throws:
IOException
-
readtextfile
public static String readtextfile(Reader rdr) throws IOException
- Throws:
IOException
-
writebinaryfile
public static void writebinaryfile(byte[] content, File dst) throws IOException
- Throws:
IOException
-
-