java代码生成短链接 java实现长链接

用Java调用短信接口给手机发送短信怎么写代码??接口已经有了,是一个url.那java代码生成短链接你要做java代码生成短链接的就是向这个URL发送数据就好java代码生成短链接 , 给个例子java代码生成短链接:
publicclassHttptest1{
8
9publicstaticvoidmain(String[] args){
10
11URL url=null ;
12HttpURLConnection conn=null ;
13OutputStream outStream=null ;
14InputStream inStream=null ;
15
16try{
17url=newURL( "" );
18conn=(HttpURLConnection) url.openConnection();
19conn.setDoOutput( true );
20conn.setDoInput( true );
21
22String sendXml=" ?xml version=\ " 1.0 \ "encoding=\ " UTF - 16 \ " ?!DOCTYPE SigMailCommand SYSTEM \ " SigMail.dtd\ " " ;// XML数据
23sendXml+=" SigMailCommand Name=\ " checkuser\ " Param Name=\ " domainname\ " test.com.cn/Param " ;
24sendXml+=" Param Name=\ " username\ " admin/Param/SigMailCommand " ;
25
26outStream=conn.getOutputStream();
27
28// 准备通过CONN对象写入XML数据
29BufferedWriter bw=newBufferedWriter( newjava.io.OutputStreamWriter(outStream,
30" UTF-16 " ));
31bw.write(sendXml);
32bw.flush();
33bw.close();
34
35// DataOutputStream dataOutStream = new DataOutputStream(outStream);
36// dataOutStream.writeChars(xml);
37// dataOutStream.flush();
38// dataOutStream.close();
39
40
41// 准备通过CONN对象读取返回java代码生成短链接的XML数据
42
43inStream=conn.getInputStream();
44StringBuffer returnXml=newStringBuffer( "" );
45BufferedReader rd=newBufferedReader( newInputStreamReader(inStream,
46" UTF-16 " ));
47for(String line=null ; (line=rd.readLine())!=null ;){
48returnXml.append(line);
49}
50System.out.println(returnXml.toString());
51rd.close();
52}catch(IOException ex){
53ex.printStackTrace();
54} finally {
55try{
56if(outStream!=null )
57outStream.close();
58if(inStream!=null )
59inStream.close();
60if(conn!=null )
61conn.disconnect();
62}catch(IOException e){
63//TODO 自动生成 catch 块
64e.printStackTrace();
65}
66}
67
68}
69
70 }
怎么用java代码把一个链接生成二维码参考代码
import java.io.*;
import java.util.Date;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
public class QRCodeEncoderTest
{
/** Creates a new instance of QRCodeEncoderTest */
public QRCodeEncoderTest()
{
}
public static void create_image(String sms_info)throws Exception{
try{
qrcode testQrcode =new qrcode();
testQrcode.setQrcodeErrorCorrect('M');
testQrcode.setQrcodeEncodeMode('B');
testQrcode.setQrcodeVersion(7);
String testString = sms_info;
byte[] d = testString.getBytes("gbk");
System.out.println(d.length);
//BufferedImage bi = new BufferedImage(98, 98, BufferedImage.TYPE_INT_RGB);
BufferedImage bi = new BufferedImage(98, 98,
阿里云OSS的java实现生成url签名的代码示例吗生成签名以后的URL的示例代码如下:
// Generate a presigned URL
Date expires = new Date (new Date().getTime()1000 * 60); // 1 minute to expire
GeneratePresignedUrlRequest generatePresignedUrlRequest =
new GeneratePresignedUrlRequest(bucketName, key);
generatePresignedUrlRequest.setExpiration(expires);
URL url = client.generatePresignedUrl(generatePresignedUrlRequest);
System.out.println(url.toString());
这段代码假定指定bucketName和key的Object已经上传到OSS,用户可以根据修改设定expires,即过期时间 。更详细的操作可以参考OSSClient#generatePresignedUrl方法和GeneratePresignedUrlRequest类的帮助 。

推荐阅读