java异常捕获
摘要:总结: 在文件输入流内,记得关闭流package com.b;import java.io.*;//使用try-catch语句捕获异常public class ygre { public static void main(String[] args) { try { int c; FileInputStream fis = new FileInputStream("lg"); while ((c = fis.read()) != -1) { System.out.println(c); } fis.close();// 再循环外面关闭文件。 } catch (Fi...
阅读全文
posted @
2013-11-11 14:07
juewang
阅读(231)
推荐(0)
java流2
摘要:总结:字符转换package com.b;//流类import java.io.*;public class uy { // 读取字符 public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); char c; do { c = (char) bf.read();// String 型 } while (c != 'p'); }}
阅读全文
posted @
2013-11-11 13:45
juewang
阅读(135)
推荐(0)
java流
摘要:总结:异常,方法、package com.b;import java.io.BufferedReader;import java.io.InputStreamReader;//流类import java.io.InputStream;public class dfa { // 读取字符串 public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String c; do { c =...
阅读全文
posted @
2013-11-11 13:23
juewang
阅读(150)
推荐(0)
32
摘要:http://josh-persistence.iteye.com/blog/1880572http://www.iteye.com/topic/681623http://denyx123.iteye.com/blog/1122157http://zhxing.iteye.com/blog/543584http://gaojianqi6.iteye.com/blog/1336626http://gaolixu.iteye.com/blog/393477
阅读全文
posted @
2013-11-10 23:53
juewang
阅读(160)
推荐(0)
java代码List
摘要:总结:代码代码你认得我吗?package com.c2;import java.util.ArrayList;//listimport java.util.List;public class hgf { public static String listToString(List stringList) { if (stringList == null) { return null; } StringBuilder result = new StringBuilder(); boolean flag = true;// 这是个循环变量吗? for (String string :...
阅读全文
posted @
2013-11-10 22:57
juewang
阅读(216)
推荐(0)
java代码输入流篇2
摘要:总结:方法。和之前的有不同,但是名字太长了+++++package com.aini;import java.io.*;public class ghd { public static void main(String[] args) { BufferedWriter out = null; try { out = new BufferedWriter(new BufferedWriter(out)); out.write("DFA");// 字符串型。。。 } catch (Exception E) { E.printStackTrace(); } }}
阅读全文
posted @
2013-11-10 22:38
juewang
阅读(162)
推荐(0)
java流类练习前篇
摘要:总结:package com.aini;import java.io.*;public class gf { public static String main(String[] args) throws IOException { BufferedWriter out = null;// H try { // out=new BufferedWriter(out);//cuo le out = new BufferedWriter(new FileWriter("filename", true)); out.write("MISS LANG a wo"
阅读全文
posted @
2013-11-10 22:28
juewang
阅读(168)
推荐(0)
java流网址:
摘要:http://wenwen.soso.com/z/q218252928.htmhttp://zhidao.baidu.com/question/463015244.html
阅读全文
posted @
2013-11-10 22:27
juewang
阅读(111)
推荐(0)
java中i/o练习
摘要:总结:FileInputStream fis;int length;while((length=fis.read(b,0,b.length))!=-1){ output.write(b,0,length);}}catch(){}finally{if(fis!=null) fis.close();if(output!=null) output.close();}return output.toByteArray();package com.aini;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.*.
阅读全文
posted @
2013-11-10 21:48
juewang
阅读(240)
推荐(0)
java代码I/O类
摘要:总结:流类无法理解啊——————package com.aini;import java.io.*;//流类//使用FileInputStream读取文件信息 public class ffg {// 这个byte真的是个字节方法。。。一个不能错 public static byte[] readFileByFileInputStream(File file) throws IOException { ByteArrayOutputStream oot = new ByteArrayOutputStream(); FileInputStream fis = null; try { ...
阅读全文
posted @
2013-11-10 21:15
juewang
阅读(222)
推荐(0)
java代码i/o流类
摘要:总结:BufferedInputStream();package com.aini;import java.io.*;//使用BufferedInputStream读取文件public class yhtrds { //这是一个方法 public static byte[] readFileByBufferedInputStream(File file){ BufferedInputStream bis; FileInputStream fis; ByteArrayOutputStream ot=new ByteArrayOutputStream();//字节数组输出流 try{/...
阅读全文
posted @
2013-11-10 20:54
juewang
阅读(209)
推荐(0)
java中I/O类
摘要:总结:输入流/输出流方法,变量;package com.aini;//流类。输入输出流import java.io.*;public class rtyeew {// (File file)这里是方法传递参数的意思吗。 public static void copyFileByFileOutputStream(File file) throws IOException { FileInputStream fis = null;// 复制 FileOutputStream fos = null;// 由于后面要关闭文件,所以这里要声明是null byte[] b = new byte[20...
阅读全文
posted @
2013-11-10 20:18
juewang
阅读(231)
推荐(0)
java代码流类
摘要:总结:package com.aini;import java.io.*;public class tre { public static void main(String[] args) { int b; try { System.out.println("Please input:"); while ((b = System.in.read()) != -1) { System.out.print((char) b); } } catch (IOException e) { System.out.println(e.toString()); } }}//Ple...
阅读全文
posted @
2013-11-10 12:12
juewang
阅读(243)
推荐(0)
java代码字符字节流
摘要:总结:package com.aini;import java.io.IOException;import java.io.InputStreamReader;//流类 import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.FileNotFoundException;import java.io.OutputStreamWriter;import java.io.FileOutputStream;import java.io.OutputStreamWriter;import java.io.
阅读全文
posted @
2013-11-10 10:56
juewang
阅读(257)
推荐(0)
java代码随机数100个,10个一输出显示======
摘要:总结:空格???懂否?如何显示for(int i=0;i<100;i++){if(i%10==0){System.out.println();}System.out.print(n[i]);//这种空格控制类型。类似打印星星。金字塔形,直角,等腰。好好琢磨}package com.da;//输出10个一行的随机数 //100个数10个一行的输出import java.util.Random;public class hk { public static void main(String[] args) {// 这里输出随机数 int n[] = new int[100];// 定义一个1
阅读全文
posted @
2013-11-09 23:51
juewang
阅读(1127)
推荐(0)
java代码异常普通的====
摘要:总结:对于各种流类,package com.da;//包括运行异常,和非运行异常import java.io.*;public class ryl { public static void main(String[] args) { try { FileInputStream fis = new FileInputStream("log.txt"); int s; while ((s = fis.read()) != -1) { System.out.println(s); } fis.close(); } catch (FileNotFoundException...
阅读全文
posted @
2013-11-09 22:12
juewang
阅读(237)
推荐(0)
java代码异常处理篇-----循环
摘要:总结:注意一个方法:nextLine();它表示:执行当前行,返回跳过的输入信息。package com.da;import java.util.InputMismatchException;import java.util.Scanner;//从键盘输入数,判断,是double型则输出。通过循环变量退出do-while循环//若不是,则系统提示异常,该异常被catch语句捕获。catch语句用来显示数据输入错误提示信息。//并提示用户重新输入,然后通过循环变量使do-while循环继续执行。 要求用户重新输入//其中 Scanner中的方法 String nextline()的作用是:...
阅读全文
posted @
2013-11-09 21:52
juewang
阅读(1198)
推荐(0)
java代码异常篇
摘要:总结:掌握流。缓冲区类的方法package com.b;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;public class Mark { public static void main(String[] args) throws Exception { Stream st = new Stream("log.txt"); }}class Stream { public Stream(String pathName) throws Exception { Buffer
阅读全文
posted @
2013-11-09 10:06
juewang
阅读(203)
推荐(0)
java代码异常处理
摘要:总结:运用throw和throws抛出异常,在哪一种情况下该怎么抛出异常。重要package com.b;//异常中throwe和throws的用法public class yz { public static void main(String[] args) { System.out.println("新浪微博-----"); try{ System.out.println(1/0); }catch(ArithmeticException e){ System.out.println("除数不为0"); } System.out.println(&qu
阅读全文
posted @
2013-11-09 09:46
juewang
阅读(193)
推荐(0)
java代码split分割数字类
摘要:总结:正则表达式--package com.c2;//写一个spli的用法,数字类 ===分割字符串 public class yqw { public static void main(String[] args) { String a = "192.168.43.130"; String c[] = a.split("\\.");// 数组 for (int i = 0; i < c.length; i++) { System.out.println(c[i]); } }}//19216843130
阅读全文
posted @
2013-11-08 14:14
juewang
阅读(3169)
推荐(0)