易截截图软件、单文件、免安装、纯绿色、仅160KB

java学习笔记

最近学习java的IO操作,现整理如下
1   输入输出
  java的库将程序与输入有关的类都从InputStream继承,与输出有关的类都从OutStream继承。
以前没有掌握的相关类  SequenceInputStream 将两个或更多的inputStream 转换成单个对象使用。
2 增添属性和有用的接口
装饰器 : 利用层次化对象动态透明的增加单个对象的能力的做法叫做“装饰器” 
3 输入
对一个文件进行输入操作,需要一个FileInputStream 对象,为提高速度需要对文件进行缓冲处理 BufferedInputStream  ,为了以格式化的形式读取数据,我们使用了DataInputStream 来进行处理。 
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(args[0]))); 
4 快速文件输入
class InFile extends DataInputStream {

public InFile(String fileName) throws FileNotFoundException{
super(new BufferedInputStream(new FileInputStream(fileName)));
}

public InFile(File file) throws FileNotFoundException{
super(new BufferedInputStream(new FileInputStream(file.getPath())));
}
}
这样设计可以避免每次重复够造 。
同样快速文件输出可以按照上述的格式进行构造。
5 Reader Writer 
inputstream 是字节流 ,二reader是字符流 传递unicode 。
要使用readLine()应该使用BufferedReader ,二不应该再使用DataInputStream 
6 重导向标准IO package cn.bupt.io;
import java.io.*;
public class Redirect {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedInputStream in = null ;
try {
in = new BufferedInputStream(new FileInputStream(args[0]));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
PrintStream out = null ;

try {
out = new PrintStream(new BufferedOutputStream(new FileOutputStream(args[1]))) ;
} catch (FileNotFoundException e) {
e.printStackTrace();
}


System.setIn(in) ;
System.setOut(out) ;
System.setErr(out) ;


BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = null ;
try {
whil


相关文档:

Java另一种分页技术

 整体系统采用Java中Spring ,Struts, Hibernate组成。
在Action中:
public ActionForward orgview(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) {
// TODO Auto-generated method stub
ActionForward forward = new ActionForward("strpath");
Http ......

Java List遍历方法 及其效率对比

One:14109
Two:14000
Three:15141
four:14297
package com.zbalpha.test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListTest {
    public static void main(String args[]){
        List<Long> ......

java对象的大小与引用类型

本文来自和你在一起的博客,原文标题:《JVM调优总结(二)-一些概念》。本文总结了JVM概念中的Java对象的大小,以及三种引用类型的定义与区分。 基本数据的类型的大小是固定的,这里就不多说了。对于非基本类型的Java对象,其大小就值得商榷。 在Java中,一个空Object对象的大小是8byte,这个大小只是保存堆中一个没有任 ......

关于Java中BorderLayout布局的一个纠结问题,求教

这个问题在于  在Frame中添加组件时,每个组件先设定了位置,但是添加到Frame中后始终会出现问题。
例如:
class MyGame extends Frame

 
 MyGame()
 {
  Label c[] = new Label[8];
  for(i = 0; i<8; i++)
  {
   c[i] = new Lab ......

用Java获得IP地址

     
如何用Java获得一个域名的IP地址呢?提供这个功能的类叫做java.net.InetAddress。我们假设现在有这样一个域名,它用一个静态的
getByName来重新获得一个InetAddress,然后得到可以读出的IP地址。下面的代码是非常基本的命令行。
import java.net.InetAddress;
import java.net.Unknow ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号