Java fragments such as parsequerystring

Source: Internet
Author: User

Public static hashtable parsequerystring (string S)
{
Object OBJ = NULL;
If (S = NULL)
Throw new illegalargumentexception ();
Hashtable = new hashtable ();
Stringbuffer = new stringbuffer ();
String as [];
String S2;
For (stringtokenizer = new stringtokenizer (S, "&"); stringtokenizer. hasmoretokens (); hashtable. Put (S2, ))
{
String S1 = stringtokenizer. nexttoken ();
Int I = s1.indexof (61 );
If (I =-1)
Throw new illegalargumentexception ();
S2 = parsename (s1.substring (0, I), stringbuffer );
String S3 = parsename (s1.substring (I + 1, s1.length (), stringbuffer );
If (hashtable. containskey (S2 ))
{
String AS1 [] = (string []) hashtable. Get (S2 );
As = new string [as1.length + 1];
For (Int J = 0; j <as1.length; j ++)
As [J] = AS1 [J];

As [as1.length] = S3;
} Else
{
As = new string [1];
As [0] = S3;
}
}

Return hashtable;
}

This is a method of httputil In the servlet package, where
String S = "ABCDE & fgh61 = klklkl ";
System. Out. println ("S. indexof (61):" + S. indexof (61 ));
 
Indexof returns the equal sign position in the string.

2.
File file;
File = file. createtempfile ("policy", "pdf ");
System. Out. println (file. getname ());
This statement returns a temporary file similar to policy % PDF. The first parameter is the prefix of the file name, the second parameter is the suffix of the file name, and the third parameter can not be specified (mark the path of the temporary file directory)

System. Out. println (file. getabsolutefile (); or
System. Out. println (file. getabsolutepath (); returns the absolute path of the temporary file:
C: \ release E ~ 1 \ admini ~ 1 \ locals ~ 1 \ temp \ policy26872pdf

System. Out. println (file. GetCanonicalPath (); a comparison rule string is returned:
C: \ Documents and Settings \ Administrator \ Local Settings \ temp \ policy58766pdf

System. Out. println (file. getparent (); ===" c: \ police ~ 1 \ admini ~ 1 \ locals ~ 1 \ Temp

System. Out. println (file. touri (); ===" file:/C:/example E ~ 1/admini ~ 1/locals ~ 1/temp/policy45597pdf
System. Out. println (file. tourl (); ===" file:/C:/docume ~ 1/admini ~ 1/locals ~ 1/temp/policy45597pdf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.