• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading an MP3 from a URL to a local file

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to copy an MP3 from my website to a local file - the following program SOMETIMES!!?? works, sometimes it get so far and then stops -it does not end just sticks at a random point,and i have to cancel the program ( I am using Netbeans), but it does work on the odd occasion?! my main aim to have this in a swing application using swingworker, and to update a status bar etc.....

Any help would be greatly appreciated!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

That > 0 should be >= 0, > -1 or != -1. 0 itself is a perfectly valid return value that does not indicate the end of the stream. That's what -1 is for.
 
Petereyup Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried !=-1 and >=0, it still sometimes works and sometimes just get stuck within the loop, but no new println's are produced - it just hangs!

Thanks for the tip though!
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you've modified the loop as I suggested, then I don't see anything wrong with your code. Perhaps there is a problem with the network, or with the server you're getting the MP3 file from. Can you download the file from a regular browser?
 
Petereyup Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering if it was the network - sometimes when I watch a streamed video through BBC's Iplayer, it stops ,then starts again with the sound out of sink with the video, and internet radio sometimes just stops!! - I will try it on a friends network.

Thanks
 
Petereyup Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done some more research : downloading small(ish) files works fine, but larger files can just freeze the program.

What I have found out, is the connection could be timing out after a certain time, I then thought could it be done using FTP - I use FileZilla and that works! - Nope does the same.

Can anyone please give any suggestions - could something to do with sockets work ( I am what you might call a beginner to java!)

Thanks
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If FileZilla has the same problem, the problem is somewhere in the network. Since the problem is not limited to this one server, that problem can be your network card drivers, network card itself, cable, or anything beyond that. Start locally, by reinstalling / updating the network card drivers, then work your way along the line.
 
Petereyup Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry - FileZilla DOES work - that's what's weird!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic