Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 22649
126
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: 22649
126
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: 22649
126
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!
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic