‘JAVA’ カテゴリーのアーカイブ

java byte配列コピー2

2009年12月24日 木曜日

Systemに何故かcopyメソッドが存在?

System.arraycopy(src, 0, dst, count, len);

java byte配列のコピー

2009年12月24日 木曜日

FileInputStream fis=null;
  try {
   fis = new FileInputStream(fileName);
 
   int count = 0;
   int len;
   byte [] src = new byte[1024];
   try {

 while ((len = fis.read(dst, count, len )) != 0) {  // 読み込み
  count+=len;
 }
   } catch (IOException e) {
    e.printStackTrace();
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }finally{
   try {
    if(fis != null) {
     fis.close();
    }
   } catch (IOException e) {
    e.printStackTrace();
   }
  }