Examples of TorrentFile


Examples of org.eclipse.ecf.protocol.bittorrent.TorrentFile

  PeerConnection(ConnectionPool pool, TorrentManager manager)
      throws UnsupportedEncodingException {
    this.pool = pool;
    this.manager = manager;
    TorrentFile torrent = manager.getTorrentFile();
    StringBuffer buffer = new StringBuffer(PROTOCOL_STRING);
    synchronized (buffer) {
      buffer.append(torrent.getInfoHash());
      buffer.append(manager.getPeerID());
    }
    handshake = buffer.toString().getBytes("ISO-8859-1"); //$NON-NLS-1$
    peerPieces = new boolean[torrent.getNumPieces()];
    haveMessages = new boolean[peerPieces.length];
    Arrays.fill(peerPieces, false);
    Arrays.fill(haveMessages, false);
  }
View Full Code Here

Examples of org.eclipse.ecf.protocol.bittorrent.TorrentFile

    super(url);
  }

  public void connect() throws IOException {
    if (torrent == null) {
      torrent = TorrentFactory.createTorrent(new TorrentFile(new File(url
          .getFile())));
      torrent.start();
    }
  }
View Full Code Here

Examples of org.eclipse.ecf.protocol.bittorrent.TorrentFile

        if (localFileToSave.exists() && !localFileToSave.canWrite()) {
          throw new IOException("file="+localFileToSave.getAbsolutePath()+" does not exist or cannot be written to"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        final TorrentFile file = new TorrentFile(((TorrentID) remoteFileReference).getFile());
        file.setTargetFile(localFileToSave);
        final Torrent torrent = TorrentFactory.createTorrent(file);
        transfer = new TorrentFileTransfer(remoteFileReference, transferListener, torrent);
        return transfer;
      }

      public IIncomingFileTransfer receive(File localFileToSave, FileTransferJob fileTransferJob) throws IOException {
        if (cancelled) {
          throw new RuntimeException(new UserCancelledException());
        }

        Assert.isNotNull(localFileToSave, "localFileToSave must not be null"); //$NON-NLS-1$

        if (localFileToSave.exists() && !localFileToSave.canWrite()) {
          throw new IOException("file="+localFileToSave.getAbsolutePath()+" does not exist or cannot be written to"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        final TorrentFile file = new TorrentFile(((TorrentID) remoteFileReference).getFile());
        file.setTargetFile(localFileToSave);
        final Torrent torrent = TorrentFactory.createTorrent(file);
        transfer = new TorrentFileTransfer(remoteFileReference, transferListener, torrent);
        return transfer;
      }
View Full Code Here

Examples of org.torrcast.model.TorrentFile

            @RequestParam(value = "id", required = true) int id,
            HttpServletResponse response) throws IOException {

//        logger.debug("Data:" + torrentFile.getData());

        TorrentFile torrentFile = podcastDao.getTorrentFile(id);
        response.setContentType("application/x-bittorrent");
        response.setHeader("Content-Disposition", "attachment; filename=\"test_torrent.torrent\"");
        response.getOutputStream().write(torrentFile.getData());
    }
View Full Code Here

Examples of org.torrcast.model.TorrentFile

                System.out.println("Hashing the files...");
                System.out.flush();
                tp.generatePieceHashes();
                System.out.println("Hash complete... Saving...");

                TorrentFile torrentFile = new TorrentFile(tp.generateTorrent(item.getFileUrl()));
               
                torrent.setCreatedDate(new Date());
                torrent.setFile(torrentFile);

                OutputStream fos = new FileOutputStream("/tmp/file-989.mp3.torrent");
                fos.write(torrentFile.getData());

//                 Save the new data (TorrentFile & Torrent).
//                podcastDao.storeTorrent(torrent);
               
                item.setTorrent(torrent);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.