符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
person类的代码:
创新互联公司专业为企业提供兴和网站建设、兴和做网站、兴和网站设计、兴和网站制作等企业网站建设、网页设计与制作、兴和企业网站模板建站服务,10年兴和做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.BooleanWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
public class Person implements Writable {
//相当于String类型
private Text name;
public Text getName() {
return name;
}
public void setName(Text name) {
this.name = name;
}
public IntWritable getAge() {
return age;
}
public void setAge(IntWritable age) {
this.age = age;
}
public BooleanWritable getMale() {
return male;
}
public void setMale(BooleanWritable male) {
this.male = male;
}
private IntWritable age;
private BooleanWritable male;
//序列化
public void write(DataOutput out) throws IOException{
name.write(out);
age.write(out);
male.write(out);
}
//反序列化
public void readFields(DataInput in) throws IOException{
name = new Text();
age=new IntWritable();
male=new BooleanWritable();
name.readFields(in);
age.readFields(in);
male.readFields(in);
}
}
测试类的代码:
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import org.apache.hadoop.io.BooleanWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.junit.Test;
public class TestPerson {
@Test
public void testSeria() throws Exception{
//new person
Person p = new Person();
p.setName(new Text("tomas"));
p.setAge(new IntWritable(12));
p.setMale(new BooleanWritable(false));
//序列化
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(baos);
p.write(dataOut);
dataOut.close();
//反序列化
Person newPerson = new Person();
newPerson.readFields(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
System.out.println(newPerson.getName());
System.out.println(newPerson.getAge().get());
}
}