笔记本共享无线上网
2008-08-19 03:53
239 查看
/**
* <p>Title: base64编码</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: atdm</p>
*
* @author zhongxun
* @version 1.0
*/
public class BASE64Encoder {
private static char[] codec_table = { 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '+', '/' };
public BASE64Encoder() {
}
public String encode(byte[] a) {
int totalBits = a.length * 8;
int nn = totalBits % 6;
int curPos = 0;// process bits
StringBuffer toReturn = new StringBuffer();
while (curPos < totalBits) {
int bytePos = curPos / 8;
switch (curPos %
![](http://www.iteye.com/images/smiles/icon_cool.gif)
{
case 0:
toReturn.append(codec_table[(a[bytePos] & 0xfc) >> 2]);
break;
case 2:
toReturn.append(codec_table[(a[bytePos] & 0x3f)]);
break;
case 4:
if (bytePos == a.length - 1) {
toReturn
.append(codec_table[((a[bytePos] & 0x0f) << 2) & 0x3f]);
} else {
int pos = (((a[bytePos] & 0x0f) << 2) | ((a[bytePos + 1] & 0xc0) >>
6)) & 0x3f;
toReturn.append(codec_table[pos]);
}
break;
case 6:
if (bytePos == a.length - 1) {
toReturn
.append(codec_table[((a[bytePos] & 0x03) << 4) & 0x3f]);
} else {
int pos = (((a[bytePos] & 0x03) << 4) | ((a[bytePos + 1] & 0xf0) >>
4)) & 0x3f;
toReturn.append(codec_table[pos]);
}
break;
default:
//never hanppen
break;
}
curPos+=6;
}
if(nn==2)
{
toReturn.append("==");
}
else if(nn==4)
{
toReturn.append("=");
}
return toReturn.toString();
}
}
我就是希望在服务器上能把图片文件通过这个方法解析发个服务器后在解析回来,data数组就可以了.服务端解析怎么写,谢谢大家了,希望打家帮个忙.
看不清的话下面有代码. 那个图像是个8的数字
* <p>Title: base64编码</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: atdm</p>
*
* @author zhongxun
* @version 1.0
*/
public class BASE64Encoder {
private static char[] codec_table = { 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '+', '/' };
public BASE64Encoder() {
}
public String encode(byte[] a) {
int totalBits = a.length * 8;
int nn = totalBits % 6;
int curPos = 0;// process bits
StringBuffer toReturn = new StringBuffer();
while (curPos < totalBits) {
int bytePos = curPos / 8;
switch (curPos %
![](http://www.iteye.com/images/smiles/icon_cool.gif)
{
case 0:
toReturn.append(codec_table[(a[bytePos] & 0xfc) >> 2]);
break;
case 2:
toReturn.append(codec_table[(a[bytePos] & 0x3f)]);
break;
case 4:
if (bytePos == a.length - 1) {
toReturn
.append(codec_table[((a[bytePos] & 0x0f) << 2) & 0x3f]);
} else {
int pos = (((a[bytePos] & 0x0f) << 2) | ((a[bytePos + 1] & 0xc0) >>
6)) & 0x3f;
toReturn.append(codec_table[pos]);
}
break;
case 6:
if (bytePos == a.length - 1) {
toReturn
.append(codec_table[((a[bytePos] & 0x03) << 4) & 0x3f]);
} else {
int pos = (((a[bytePos] & 0x03) << 4) | ((a[bytePos + 1] & 0xf0) >>
4)) & 0x3f;
toReturn.append(codec_table[pos]);
}
break;
default:
//never hanppen
break;
}
curPos+=6;
}
if(nn==2)
{
toReturn.append("==");
}
else if(nn==4)
{
toReturn.append("=");
}
return toReturn.toString();
}
}
我就是希望在服务器上能把图片文件通过这个方法解析发个服务器后在解析回来,data数组就可以了.服务端解析怎么写,谢谢大家了,希望打家帮个忙.
看不清的话下面有代码. 那个图像是个8的数字
相关文章推荐
- 两台无线笔记本共享上网
- ipad&nbsp;共享笔记本的无线网卡上网
- win7下,两台笔记本内置的无线局域网卡共享上网
- 笔记本无线网卡共享上网
- 笔记本无线共享上网
- 【WIN7深度揭秘】将你的笔记本打造成WI-FI基站实现无线共享上网
- 【转】windows7 系统下实现两台笔记本内置的无线局域网卡共享上网的设置方法
- 两台笔记本无线互连共享上网
- 办公室笔记本有线连接上网,利用自带的无线网卡共享网络使iPhone上网
- 笔记本无线共享上网
- 两台笔记本通过无线连接共享上网
- 笔记本无线共享上网教程
- 用SonBuddy搭建无线局域网,共享上网。(SONBuddy常见问题,无线组网,共享,上网,笔记本)
- 扔掉路由,两台笔记本无线共享一根网线上网
- 两台笔记本无线共享上网
- Windows平台ipod touch/iphone等共享笔记本无线上网设置大全
- 带无线网卡的笔记本和wifi手机共享上网
- 让你的win7笔记本变身无线路由,让手机,平板.笔记本,支持WIFI的无线设备可以共享上网
- Windows平台ipod touch/iphone等共享笔记本无线上网设置大全
- 电脑爱好者要知道的笔记本无线网卡共享上网配置