当前位置:  编程技术>移动开发
本页文章导读:
    ▪ZiP资料加密        ZiP文件加密 接到客户的需求,要求实现,ZIP文件夹解密,功能,找了已很久发现,这方面的资料确实很匮乏。贴出源码 和大家分享。 package com.hongan.test; import java.io.File; import android.app.Activi.........
    ▪ java socket 兑现get post 请求        java socket 实现get post 请求import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.net.UnknownHostException; .........
    ▪ ios学习札记(三)UISlider与UISwitch控件       ios学习笔记(三)UISlider与UISwitch控件1 首先我们还是创建一个Single View Application,然后打开MainStoryboard_iphone.storyboard,在IB中添加一个UISlider控件和一个Label,这个Label用来显示Slider的值。 选中新.........

[1]ZiP资料加密
    来源: 互联网  发布时间: 2014-02-18
ZiP文件加密

接到客户的需求,要求实现,ZIP文件夹解密,功能,找了已很久发现,这方面的资料确实很匮乏。贴出源码 和大家分享。

package com.hongan.test;

import java.io.File;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class PassWordZipDemoActivity extends Activity {
/** Called when the activity is first created. */

Button btn_jiemi, btn_jiami;
ZipFileWithPassword zipFileWithPassword;
String filePath;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


btn_jiemi=(Button) this.findViewById(R.id.jiemi);
btn_jiami=(Button) this.findViewById(R.id.jiami);
zipFileWithPassword=new ZipFileWithPassword();
filePath=ZipFileWithPassword.zipDir;

btn_jiemi.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
zipFileWithPassword=new ZipFileWithPassword();
zipFileWithPassword.newFolder();
zipFileWithPassword.TestDecryptZipFile();
}
});
btn_jiami.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
zipFileWithPassword.TestEncryptZipFile();
File file=new File(filePath);
Log.i("infor","filePath is"+ filePath);

deleteFile( file);
//file.delete();

}
});
}
private void deleteFile(File file){
if(file.exists()){
if(file.isFile()){
file.delete();
}else if(file.isDirectory()){
File files[] = file.listFiles();
for(int i=0;i<files.length;i++){
this.deleteFile(files[i]);
}
}
file.delete();
}else{
Log.i("infor","所删除的文件不存在!"+'\n');
}
}
}

   Demo源码



    
[2] java socket 兑现get post 请求
    来源: 互联网  发布时间: 2014-02-18
java socket 实现get post 请求
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;


class HttpRequestBean {
private String ip;
private String realm;
private int port;
private String url;
private String params;
private boolean isPOST;


// getter 、setter方法略
public String getIp() {
return ip;
}


public void setIp(String ip) {
this.ip = ip;
}


public String getRealm() {
return realm;
}


public void setRealm(String realm) {
this.realm = realm;
}


public int getPort() {
return port;
}


public void setPort(int port) {
this.port = port;
}


public String getUrl() {
return url;
}


public void setUrl(/blog_article/String url/index.html) {
this.url = url;
}


public String getParams() {
return params;
}


public void setParams(String params) {
this.params = params;
}


public boolean isPOST() {
return isPOST;
}


public void setPOST(boolean isPOST) {
this.isPOST = isPOST;
}


}


public class HttpSocketUtil {
private static String httpPOSTSocket(String ip, String realm, int port,
String url, String params) throws UnknownHostException, IOException {
Socket s = new Socket(ip, port);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s
.getOutputStream()));
if (url.startsWith("/")) {
url = url.substring(1);
}
int index2 = url.indexOf("?");
if (index2 > 0) {
url = url.substring(0, index2);
}
pw.println("POST " + url + " HTTP/1.1");
pw.println("Host:" + realm);
pw.println("Accept-Language: zh-cn,zh;q=0.5");
pw.println("Accept-Encoding: gzip,deflate");
pw.println("Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7");
pw.println("Connection: keep-alive");
pw.println("Cookie: ASPSESSIONIDCSAATTCD=DOMMILABJOPANJPNNAKAMCPK");
pw.println("Content-Type: application/x-www-form-urlencoded");
int leng = params.length();
pw.println("Content-Length: " + leng);
pw.println();
pw.println(params);
pw.println();
pw.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(s
.getInputStream()));
String temp = null;
while((temp = br.readLine()) != "")
{
System.out.println(temp);
}
br.close();
pw.close();
s.close();
return temp;
}


public static String httpSocket(HttpRequestBean httpBean)
throws UnknownHostException, IOException {
if (httpBean.isPOST()) {
System.out.println("POST");
return httpPOSTSocket(httpBean);
} else {
System.out.println("GET...");
return httpGETSocket(httpBean);
}
}


private static String httpGETSocket(String ip, String realm, int port,
String url) throws UnknownHostException, IOException {
Socket s = new Socket(ip, port);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s
.getOutputStream()));
if (url.startsWith("/")) {
url = url.substring(1);
}
pw.println("GET " + url + " HTTP/1.1");
pw.println("Host:" + realm);
pw.println("Accept-Language: zh-cn,zh;q=0.5");
pw.println("Accept-Encoding: gzip,deflate");
pw.println("Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7");
pw.println("Connection: keep-alive");
// pw.println("Cookie: ASPSESSIONIDCSAATTCD=DOMMILABJOPANJPNNAKAMCPK");
pw.println("Content-Type: text/http");
pw.println();
pw.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(s
.getInputStream()));
String temp = null;
while((temp = br.readLine()) != "")
{
System.out.println(temp);
}
br.close();
pw.close();
s.close();
return temp;
}


private static String httpPOSTSocket(HttpRequestBean httpBean)
throws UnknownHostException, IOException {
return httpPOSTSocket(httpBean.getIp(), httpBean.getRealm(), httpBean
.getPort(), httpBean.getUrl(), httpBean.getParams());
}


private static String httpGETSocket(HttpRequestBean httpBean)
throws UnknownHostException, IOException {
return httpGETSocket(httpBean.getIp(), httpBean.getRealm(), httpBean
.getPort(), httpBean.getUrl());
}


public static void main(String[] args) {
String content = null;
HttpRequestBean httpBean = new HttpRequestBean();
String ip = "www.cnblogs.com";
httpBean.setIp(ip);
httpBean.setParams("tbUserName=123");
httpBean.setPort(80);
//httpBean.setUrl("http://www.cnblogs.com/");
httpBean.setUrl("http://passport.cnblogs.com/login.aspx");
httpBean.setPOST(true);
httpBean.setRealm(ip);
try {
content = httpSocket(httpBean);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(content);
}


    
[3] ios学习札记(三)UISlider与UISwitch控件
    来源: 互联网  发布时间: 2014-02-18
ios学习笔记(三)UISlider与UISwitch控件

1 首先我们还是创建一个Single View Application,然后打开MainStoryboard_iphone.storyboard,在IB中添加一个UISlider控件和一个Label,这个Label用来显示Slider的值。

选中新加的Slider控件,打开Attribute Inspector,修改属性值,设置最小值为0,最大值为100,当前值为0.5,并确保勾选上Continuous,如下图:

接着我们放上UISwitch控件,就是很像开关的那种控件,它只有两个状态:on和off,全都放上去效果就是这样的:



2.好了我们开始写代码喽:ViewController.h:


接着是实现 ViewController.m:


3.剩下的就是连接操作和输出口:

将slider控件的value changed事件与sliderChanged方法连接在一起,将swich控件的value changed事件与swichChanged方法连接在一起,当然还要把lable控件和swich控件的输出与ViewController的相应控件接口连接在一起。

最终实现的效果如下面两张图:                                                         


            



    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3