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

JAVA IO流的应用

JAVA IO流的应用
 
 
 
IO流的典型应用
尽管库内存在大量IO流类,可通过多种不同的方式组合到一起,但实际上只有几种方式才会经常用到。然而,必须小心在意才能得到正确的组合。下面这个相当长的例子展示了典型IO配置的创建与使用,可在写自己的代码时将其作为一个参考使用。注意每个配置都以一个注释形式的编号起头,并提供了适当的解释信息。
//: IOStreamDemo.java
// Typical IO Stream Configurations
import java.io.*;
import com.bruceeckel.tools.*;
public class IOStreamDemo {
  public static void main(String[] args) {
    try {
      // 1. Buffered input file
      DataInputStream in =
        new DataInputStream(
          new BufferedInputStream(
            new FileInputStream(args[0])));
      String s, s2 = new String();
      while((s = in.readLine())!= null)
        s2 += s + "\n";
      in.close();
      // 2. Input from memory
      StringBufferInputStream in2 =
          new StringBufferInputStream(s2);
      int c;
      while((c = in2.read()) != -1)
        System.out.print((char)c);
      // 3. Formatted memory input
      try {
        DataInputStream in3 =
          new DataInputStream(
            new StringBufferInputStream(s2));
        while(true)
          System.out.print((char


相关文档:

java总结 第七章

第七章
高级类特征
static
类属性由该类的所有实例共享
public static int total=0;
当total所属类被数次实例化的时候 total只有一个而不是多个
也可静态初始化static
public static int total;
static{
total=100;
}
static标记的变量或者方法由整个类(所有实例)共享
单子模式
class Single{
   ......

java总结 第八章

第八章 异常
异常
两类 错误error 系统内部错误 违例exception 其他编程错误或外在因素】
异常处理机制
抛出异常throw 当不确定为何种异常和不确定怎么处理的时候使用
捕获异常catch
try{}
catch(){}
finally{}为统一出口
fileinputstream类的成员方法read()的功能是每次从相应的(本地为asc2码)文件中读出一个字节 ......

java总结 第十章

第十章
gui应用程序设计
awt abstractwindow toolkit
gui graphical user interface
组件component
container 容器
window 顶级窗口
panel 接纳其他组件的容器 不能独立存在
必须在其他容器中(如window或applet)
frame是window子类 效果是一个窗口setvisible(true)可见
component
container
window &n ......

java的事务处理

java的事务处理,原来是这么一回事,如果对数据库进行多次操作,每一次的执行或步骤都是一个事务.如果数据库操作在某一步没有执行或出现异常而导致事务失败,这样有的事务被执行有的就没有被执行,从而就有了事务的回滚,取消先前的操作.....
JavaBean中使用JDBC方式进行事务处理
public int delete(int sID) { ......

9 Reasons Why Java EE 6 Will Save Real Money

1.Prototyping: in general (Enterprise) Java projects start with evaluation which frameworks to use. This can take from few hours, to several months (although these times are hopefully over). Java EE 6 comes with “one stop shopping”. You can download Java EE 6 with the IDE (eclipse, netbe ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号