标签:tin tom oop 指定 center fileinput -128 iso 字符流
| 类型 | 字节数 | 范围 | 
|---|---|---|
| byte | 1 | -128 ~ 127 | 
| short | 2 | -32768 ~32767 | 
| int | 4 | \(- 2^{31}\) ~ $ 2^{31} - 1$ | 
| long | 8 | |
| float | 4 | |
| double | 8 | |
| boolean | 1 | |
| char | 2 | 
注意:short、char、byte参与运算时直接抬升到int型。
思考题:
| 运算符 | 说明 | |
|---|---|---|
| & | 与 | |
| | | 或 | |
| ^ | 异或 | |
| ~ | 取反 | |
| << | 左移 | |
| >> | 右移 | |
| >>> | 无符号右移动 | 
正数的取反 + 1。
&&存在短路,&无短路操作,&通过位运算完成。
| 字符集 | 表示字节数 | |
|---|---|---|
| asc | 1个字节的7位 | |
| gb2312 | 2字节 | |
| gbk | 2字节 | |
| big5 | 5个字节 | |
| iso8859-1 | 1个字节8位 | |
| utf-8 | 中文3个字节 | |
| unicode | 2个字节,含有两个字节的头 | 
任何字符集都是asc的超集。
Unified Modeling Language,同一建模语言,使用图形化元素描述事物以及之间的关系。
rose是UML建模软件中的一种,IBM公司开发,业界使用比较普遍。Rose的安装步骤如下:
管理员运行setup.exe文件
指定安装目录,不要使用中文和空格
装后导入license文件
解决启动rose出现缺少dll文件问题
4.1)进入rose安装目录的Common目录下
4.2)复制suite objects.dll + license.dll文件到C:\Windows\System32\和C:\Windows\SysWOW64\下
启动Rose
OK
面向对象编程的特征:
输入输出流,操纵文件的读写过程。java的流架构图如下:

IO类型的划分为:
数据类型
字节流
InputStream / OutputStream
字符流
Reader / Writer
方向
输入流
InputStream / Reader
输出流
OutputStream / Writer
功能
缓冲区流
BufferedInputStream / BufferedReader / BufferedOutputStream / BufferedWriter
转换流
InputStreamReader
/**
  * 内存流
  */
@Test
public void writeByteArrayOutputStream() throws Exception {
  ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
  baos.write("abc".getBytes("unicode"));
  byte[] bytes = baos.toByteArray();
  baos.close();
  System.out.println(bytes.length);
}
/**
  * 压缩流
  */
@Test
public void testZip() throws Exception {
  FileOutputStream fos = new FileOutputStream("d:\\java\\xxx.zip") ;
  ZipOutputStream zos = new ZipOutputStream(fos) ;
  byte[] buf = new byte[1024] ;
  int len = -1 ;
  File dir = new File("d:\\java\\zip") ;
  File[] files = dir.listFiles();
  for(File f : files){
    if(f.isFile()){
      //文件名
      String fname = f.getName() ;
      FileInputStream fin = new FileInputStream(f) ;
      zos.putNextEntry(new ZipEntry(fname));
      while((len = fin.read(buf)) != -1){
        zos.write(buf , 0 , len);
      }
      fin.close();
    }
  }
  zos.close();
  fos.close();
}
/**
  * 压缩流
  */
@Test
public void testUnzip() throws Exception {
  FileInputStream fin = new FileInputStream("d:\\java\\xxx.zip") ;
  ZipInputStream zis = new ZipInputStream(fin) ;
  byte[] buf = new byte[1024] ;
  int len = 0 ;
  //
  ZipEntry entry ;
  String ouputDir = "d:\\java\\zip\\out" ;
  while((entry = zis.getNextEntry()) != null){
    String fname = entry.getName() ;
    File f = new File(ouputDir , fname) ;
    FileOutputStream fos = new FileOutputStream(f) ;
    while((len = zis.read(buf)) != -1){
      fos.write(buf , 0 , len);
    }
    fos.close();
  }
  zis.close();
}
/**
  * 串行化
  */
@Test
public void testSerial() throws Exception {
  Person p = new Person("");
  p.setId(15);
  p.setName("tomas");
  p.setAge(22);
  FileOutputStream fos = new FileOutputStream("d:\\java\\p.dat") ;
  ObjectOutputStream oos = new ObjectOutputStream(fos) ;
  oos.writeObject(p);
  oos.close();
  fos.close();
}
/**
  * 串行化
  */
@Test
public void testDeserial() throws Exception {
  FileInputStream fis = new FileInputStream("d:\\java\\ppp.dat") ;
  ObjectInputStream ois = new ObjectInputStream(fis) ;
  Person p = (Person) ois.readObject();
  ois.close();
  fis.close();
  System.out.println(p.getName());
  System.out.println(p.isMarried());
}
标签:tin tom oop 指定 center fileinput -128 iso 字符流
原文地址:https://www.cnblogs.com/xupccc/p/9594153.html