File

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shadowam/article/details/79958809
package test;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
import java.util.Arrays;


public class helloworld {


public static void main(String[] args) throws IOException {

Reader ir =  new FileReader("d:\\test.txt");
Writer ir1 =  new FileWriter("d:\\test4.txt");
char[] ch = new char[10];

URL url = new URL("https://github.com/");

InputStream is = url.openStream();

long l1 = System.currentTimeMillis();

//int read1 = is.read();
/*while(read1!=-1)
{
System.out.println(read1);
read1 = is.read();
}*/
/*while((read1 = is.read())!=-1)
{
System.out.println(read1);
}
is.close();*/
OutputStream is2 = new FileOutputStream("D:\\git.html");
byte[] bb = new byte[10];
//int len = 0;
while(ir.read(ch)!=-1)
{
ir1.write(ch, 0, ir.read(ch));
String str = new String(ch, 0, ir.read(ch));
System.out.println(str);
}
is.close();
is2.close();
long l2 = System.currentTimeMillis();
System.out.println(l2-l1);


}


}
阅读更多

没有更多推荐了,返回首页