Java编程问题

来源:互联网 发布:淘宝html 编辑:程序博客网 时间:2024/05/16 14:19
1、
java编译时,出现错误,illegal character:\65307是什么意思啊

你的System那行后的分号问题,把分号改成英文的,中文状态下的分号是;即\65307,楼主写程序的时候把中文标点关了.

2、
Java从文件一次性读入到字符串
FileInputStream in = new FileInputStream("filename");
byte[] readBytes = new byte[in.available()];
in.read(readBytes);
String string4file = new String(readBytes);


FileInputStream的available()方法返回可以不受阻塞地从此文件输入流中读取的字节数。JDK中的解释是:


Returns an estimate of the number of remaining bytes that can be read (or
skipped over) from this input stream without blocking by the next
invocation of a method for this input stream. The next invocation might be
the same thread or another thread.  A single read or skip of this
many bytes will not block, but may read or skip fewer bytes.

如果用具体数值代替in.available()效率更高,但前提是允许输入最大文件大小已知

3、
网页上的文字不能复制粘贴怎么办
工具——internet选项——安全——自定义级别
将所有脚本都选为禁用
然后按F5刷新

复制完不用后记得要改回去,不然有些功能异常

4、

tab
notepad kxw.java


在命令行,tab 显示所有文件
加首字母可搜索

按上,重复上次操作

5、

int类型输出不能用%4.0d,double才有保留几位。int可用%4d、
"%d\t"对齐、
注意除数不能为零。