/********************************************************************************* Program to demonstrate how to that file exist on rapidshare.com server using api provided by rapidshare.com Developed by : Malhar Vora Developed on : 6-1-2011 Development Status : Completed Email : vbmade2000@gmail.com WebSite : http://malhar2010.blogspot.com **********************************************************************************/ import java.net.*; import java.io.*; import java.util.*; public class RapidChecker { public static void main(String []str) { URL u=null; String temp[]; Scanner sc = null; String strurl=null; try{ sc = new Scanner(System.in); System.out.println("Enter rapidshare url to check :"); strurl = sc.nextLine(); u = new URL(strurl); //Getting fileid and filename by splaitting string into parts temp = u.getFile().split("/"); //Calling function to check file status checkRapidShareFile(Integer.parseInt(temp[2].trim()),temp[3]); } catch(Exception e) { System.out.println("Error in checking file"); } } static void checkRapidShareFile(int file,String filename) { URL u = null; InputStream is = null; DataInputStream dis = null; String s=null,url=null; String data[]; try { url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files=" +file + "&filenames=" + filename; u = new URL(url); is = u.openStream(); dis = new DataInputStream(is); s=dis.readLine(); data = s.split(","); System.out.println(data[4]); if(data[4].equals("0")) { System.out.println("File not found"); } else if(data[4].equals("1")) { System.out.println("File found"); } else if(data[4].equals("3")) { System.out.println("Server down"); } else if(data[4].equals("4")) { System.out.println("File is illegal"); } else if(data[4].equals("5")) { System.out.println("File is locked because 10 download is already done"); } else { System.out.println("Undefined response"); } } catch(Exception e) { System.out.print(e); } finally { try { dis.close(); is.close(); } catch(Exception e2) { System.out.print("Error in closing streams"); } } } }
Sunday, February 6, 2011
Using Rapidshare.com api to check file status on rapidshare.com
Labels:
Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.