Pull
Class pull is used by PullThred in class InetClient to pull files from the net.
Method pullcode initially pulls the homepage from the web. It is stored as
homepage.htm. An entry is made of the filename (sans path) in the globalfiledbase.
The file is opened and scanned for specific html and image links. Recursively
corresponding files on the links are pulled and scanned. Loopback in pulling
files is also avoided. This operation is similar to a browser pulling the files
which were selected by the user on the homepage. But here only the filenames
are displayed. After the pull operation the array of strings ie. the globalfiledbase
will contain the list of files pulled fron the net.
// filename pull.java
import java.io.*;
import java.lang.*;
import java.awt.*;
import java.net.*;
import java.util.*;
class pull extends InetClient
{
static int totalFiles = 0;
public static void pullcode( ) throws Exception
{ // pull code ******
f_modified = new boolean[1000];
if ( connected_once == true && totalFiles == 0)
totalFiles = fileindex;
fileindex = 0;
try { Thread.sleep(5000); }
catch(Exception ex){ }
String linknames[ ]; //Array of Objects(of linknamess)
linknames = new String[100];
getLinks gl;
gl = new getLinks( );
u = new URL("http://"+sint.urlname); //HTTP URL
CConnection cc = new CConnection( );
InetClient.print("\nConnecting to URL at address= "+u);
String absfilepath;
//DDD Initializing f_modified
for(int i=0; i < 1000; i++)
f_modified[i] = false;
if (connected_once == true)
{
InetClient.print("\nPulling files\n");
int cntr = 0;
for(;fileindex < totalFiles; fileindex++)
{
u = new URL(globalfiledbase_path[fileindex]);
if (fileindex == 0)
absfilepath = cc.getwebPage(u,"pagehome.html");
else
absfilepath = cc.getwebPage(u,globalfiledbase_path[fileindex]);
if (absfilepath != "")
{
cntr++;
InetClient.print(" "+settrims.mytrims(globalfiledbase_path[fileindex]));
if (cntr == 8)
{
InetClient.print("\n\n");
cntr = 0;
}
}
}
System.out.println("totalFiles: "+totalFiles+" fileindex: "+fileindex+" globalfiledbase[5]: "+globalfiledbase[5]);
return;
}
absfilepath = cc.getwebPage(u,"pagehome.html"); //this fucn is supposed to get homepage
// & abspath where stored.
InetClient.print("\nRecieved home page on harddisk "+absfilepath);
InetClient.print("\nPulling files\n");
globalfiledbase[0] = "pagehome.html";
// InetClient.print("\n=================================");
//InetClient.print("\nCopied to global dbase with name...."+globalfiledbase[fileindex]+" at loc ["+fileindex+"] & filenamelength "+globalfiledbase[fileindex].length( ));
fileindex++;
// InetClient.print("\n file index...."+fileindex);
stringSearch yy=new stringSearch( );
linknames = yy.strSearch(absfilepath); //reads homepage & return root links in linknames.
gl.createLink(linknames);
// InetClient.print("\n ------ all over -----------");
System.out.println( );
InetClient.print("\n files in the file data base : \n");
for (int i=0;i<fileindex;i++)
{
InetClient.print(" "+globalfiledbase[i]);
if ((i%8)==0)
InetClient.print("\n\n");
}
InetClient.print("\n");
} // pull code ends
}//class end
next >>
Index