Stream I/O 2 Ẻ byte Stream character Stream
:: ¹ҡѹ :: File Stream
หน้า 1 จาก 1
Stream I/O 2 Ẻ byte Stream character Stream
byte Stream
ҹҡ c://test.txt
¹ c://testCopy.txt
ѧࡵ :// ФѺ
package fileIO;
import java.io.*;
public class Byte1 {
public static void main(String [] args) {
int bRead=0;
int index=0;
try{
FileInputStream inF = new FileInputStream("c://test.txt");
FileOutputStream outF = new FileOutputStream("c://testCopy.txt");
byte b[] = new byte[99];
while(index !=-1){
index = inF.read();
if(index !=-1){
outF.write(index);
//bRead++;
}// if
}// while
inF.close();
outF.close();
File file = new File("c://testCopy.txt");
FileInputStream in = new FileInputStream(file);
// byte show[] = new byte[20];
System.out.println("---------------------------------------");
int ii = 0;
while(ii != -1){
ii = in.read();
System.out.println(ii);
}// while
}catch (IOException e) {
System.out.println(" Error is : "+e.toString());
}
}
}
ҹҡ c://test.txt
¹ c://testCopy.txt
ѧࡵ :// ФѺ
package fileIO;
import java.io.*;
public class Byte1 {
public static void main(String [] args) {
int bRead=0;
int index=0;
try{
FileInputStream inF = new FileInputStream("c://test.txt");
FileOutputStream outF = new FileOutputStream("c://testCopy.txt");
byte b[] = new byte[99];
while(index !=-1){
index = inF.read();
if(index !=-1){
outF.write(index);
//bRead++;
}// if
}// while
inF.close();
outF.close();
File file = new File("c://testCopy.txt");
FileInputStream in = new FileInputStream(file);
// byte show[] = new byte[20];
System.out.println("---------------------------------------");
int ii = 0;
while(ii != -1){
ii = in.read();
System.out.println(ii);
}// while
}catch (IOException e) {
System.out.println(" Error is : "+e.toString());
}
}
}
:: ¹ҡѹ :: File Stream
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ