A have just uploaded my "a.mp3" to my ftp;.
In my Computer it is 8,888,890 bytes, and the same is shown in a ftp file client.
I've downloaded the file and it's really 8,888,890 bytes. ok, ok , everything is all right but... but,
Now I've tested it in a Java:
InputStream in; // read from the HTTP
FileInputStream in2; // read from my HDD
try{
in2 = new FileInputStream("a.mp3"); // that's my file
URL url1 = new URL("http://something.ge/a.mp3"); // my file in my web page
in = (url1.openStream());
System.out.println(in.available() +", "+ in2.available());
}catch(Exception e){
System.out.println("Ooops!");
}
output is this:
8475, 8888890
And when I try to download it from Java, it's less that it is really;
FileInputStream in2;
FileOutputStream out;
try{
URL url1 = new URL("http://somethin/a.mp3");
in = (url1.openStream());
out = new FileOutputStream("new.mp3");
byte[] buffer = new byte[1024];
int r=0;
while(r<in.available()){
in.read(buffer);
out.write(buffer);
}
}catch(Exception e){
System.out.println("Oooooo");
}
what's happening here, could you help me please?


Sign In
Create Account


Back to top










