Java I/O常用流示例
package io;
import java.io.*;
/**
* @author 高枕吴忧
* 利用缓冲区原理,BufferedInputStream,
* 实现的文件字节流读取功能示范
*
*/
public class BufferedInOutputStream {
public BufferedInOutputStream() {
ioTest2();
}
public void ioTest2() {
FileInputStream in = null ;
BufferedInputStream bi = null;
int i= 0;
int count=0;
try{
in = new FileInputStream("D:/j/o/java2.txt");
bi = new BufferedInputStream(in);
while(( i=bi.read())!=-1) {
System.out.print((char)i);
count++;
}
System.out.println(count);
in.close();
bi.close();
}catch (IOException e){
e.printStackTrace();
}
}
public static void main(String[] args) {
new BufferedInOutputStream();
}
}
----------------------------------
package io;
import java.io.*;
/**
* @author Owner 利用缓冲区原理,BufferedInputStr
相关文档:
public class DealLockTest implements Runnable {
static String i = new String();
static String j = new String();
private String str = null;
public DealLockTest(String str) {
this.str = str;
}
public static void main(String[] args) {
new Thread(new DealLockTest("i")).start( ......
1.使用JFrame的enableEvents和processWindowEvent
//Frame1.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame {
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
this.setSize(ne ......
使用 java 进行文件拷贝 相信很多人都会用,,不过效率上是否最好呢?
最近看了看NIO决定试一试 java NIO 到底有什么性能的提升.
第一种方法:古老的方式
public static long forJava(File f1,File f2) throws Exception{
long time=new Date().getTime();
int length=2097152;
FileInp ......
最近用installanywhere做了一个安装包,卸载的时候总是出现“载入java vm时windows出现错误:3”,很不爽,上网查看原因,原来是因为中间我重新更换过jdk的版本,现在有些软件自带VM或JDK,windows系统通过注册表来管理当前系统所使用的VM和JDK路径,因此,当安装的软件JDK版本和 ......
刚刚运行java HelloWorld.class,老是说:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class
Caused by: java.lang.ClassNotFoundException: HelloWorld.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
  ......