| 34 | | try { |
|---|
| 35 | | if (url.matches("^file(.)*")) { |
|---|
| 36 | | url = url.replaceFirst("^file:([^/*])", "file:///$1"); |
|---|
| 37 | | } else url = new URL(url).toExternalForm(); |
|---|
| 38 | | |
|---|
| 39 | | URL myURL = new URL(url); |
|---|
| 40 | | File f = File.createTempFile("VA_", url.replaceFirst("^(.*)(\\..*)$", "$2")); |
|---|
| 41 | | f.deleteOnExit(); |
|---|
| 42 | | MediAnnotater.tempFiles.add(f); |
|---|
| 43 | | |
|---|
| 44 | | BufferedInputStream bis = new BufferedInputStream(myURL.openStream()); |
|---|
| 45 | | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f)); |
|---|
| 46 | | byte[] myBytes = new byte[1024*1024]; |
|---|
| 47 | | int myByteCount = bis.read(myBytes); |
|---|
| 48 | | int totalCount = myByteCount; |
|---|
| 49 | | while(myByteCount != -1) { |
|---|
| 50 | | System.out.println("We've read: " + totalCount); |
|---|
| 51 | | bos.write(myBytes, 0, myByteCount); |
|---|
| 52 | | myByteCount = bis.read(myBytes); |
|---|
| 53 | | totalCount += myByteCount; |
|---|
| 54 | | } |
|---|
| 55 | | System.out.println("We've finished loading the file"); |
|---|
| 56 | | |
|---|
| 57 | | bos.flush(); |
|---|
| 58 | | bos.close(); |
|---|
| 59 | | bis.close(); |
|---|
| 60 | | url = f.getAbsolutePath().replaceFirst("^file:/([^/])", "file://$1"); |
|---|
| 61 | | |
|---|
| 62 | | innerMovie = quicktime.std.movies.Movie.fromFile( |
|---|
| | 35 | |
|---|
| | 36 | try { |
|---|
| | 37 | |
|---|
| | 38 | File f = null; |
|---|
| | 39 | |
|---|
| | 40 | |
|---|
| | 41 | f = new File(URLDecoder.decode(url, "UTF-8").replaceAll("file:\\\\*(.*)", "$1")); |
|---|
| | 42 | |
|---|
| | 43 | if(!f.exists()) { |
|---|
| | 44 | url = new URL(url).toExternalForm(); |
|---|
| | 45 | |
|---|
| | 46 | URL myURL = new URL(url); |
|---|
| | 47 | f = File.createTempFile("VA_", url.replaceFirst("^(.*)(\\..*)$", "$2")); |
|---|
| | 48 | f.deleteOnExit(); |
|---|
| | 49 | MediAnnotater.tempFiles.add(f); |
|---|
| | 50 | |
|---|
| | 51 | BufferedInputStream bis = new BufferedInputStream(myURL.openStream()); |
|---|
| | 52 | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f)); |
|---|
| | 53 | byte[] myBytes = new byte[1024*1024]; |
|---|
| | 54 | int myByteCount = bis.read(myBytes); |
|---|
| | 55 | int totalCount = myByteCount; |
|---|
| | 56 | while(myByteCount != -1) { |
|---|
| | 57 | System.out.println("We've read: " + totalCount); |
|---|
| | 58 | bos.write(myBytes, 0, myByteCount); |
|---|
| | 59 | myByteCount = bis.read(myBytes); |
|---|
| | 60 | totalCount += myByteCount; |
|---|
| | 61 | } |
|---|
| | 62 | System.out.println("We've finished loading the file"); |
|---|
| | 63 | |
|---|
| | 64 | bos.flush(); |
|---|
| | 65 | bos.close(); |
|---|
| | 66 | bis.close(); |
|---|
| | 67 | url = f.getAbsolutePath().replaceFirst("^file:/([^/])", "file://$1"); |
|---|
| | 68 | } |
|---|
| | 69 | innerMovie = quicktime.std.movies.Movie.fromFile( |
|---|