Program checking faculty absent list
2 posters
Page 1 of 1
Program checking faculty absent list
Reserved LOL
Last edited by ThienDinh on Fri Nov 30, 2012 9:59 pm; edited 1 time in total
Program checking faculty absent list [Coming soon]
That Will Be Sick, And Very Useful!!
Petahwil- Posts : 8
Join date : 2012-11-30
Age : 31
Re: Program checking faculty absent list
OK, Just done the program!!!
- Code:
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author ThienDinh
*/
public class QCCAbsentList {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws MalformedURLException, IOException
{
// TODO code application logic here
String address = "http://www2.qcc.mass.edu/facAbsence/default.asp";
URL pageLocation = new URL(address);
Scanner in = new Scanner(pageLocation.openStream());
ArrayList<String> goodInputs = new ArrayList<>();
String openTag = "<strong>";
while (in.hasNextLine())
{
String line = in.nextLine();
if (line.length() > openTag.length())
{
goodInputs.add(line);
}
}
ArrayList<String> names = getNames(goodInputs, openTag);
System.out.println("Faculty Absence List:");
for(int i = 0; i < names.size(); i++)
{
System.out.println(names.get(i));
}
}
public static ArrayList<String> getNames(ArrayList<String> goodInputs, String openTag)
{
ArrayList<String> names = new ArrayList<>();
for (int index = 0; index < goodInputs.size(); index++) // Run lines
{
int i = 0;
int j = i + openTag.length() - 1;
while(j < goodInputs.get(index).length())
{
String subString = goodInputs.get(index).substring(i, j + 1);
if(subString.equals(openTag))
{
names.add(getValue(goodInputs.get(index), j));
}
i++;
j = i + openTag.length() - 1;
}
}
return names;
}
public static String getValue(String line, int tagIndex)
{
String value = "";
for(int i = tagIndex + 1; i < line.length(); i++)
{
if(line.charAt(i) == '<')
{
value += line.substring(tagIndex + 1, i);
break;
}
}
return value;
}
}
Re: Program checking faculty absent list
Sooo sick that this works!! No more going on the stupid school website!! XD
Petahwil- Posts : 8
Join date : 2012-11-30
Age : 31
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sat Feb 15, 2014 10:12 am by doriperni
» Sync2 V2.20.1312 X86x64.rar.rar
Fri Feb 14, 2014 7:37 pm by carmibire
» 9.1 Inheritance Hierarchies
Tue Feb 26, 2013 12:50 pm by ThienDinh
» Useful website
Sat Dec 08, 2012 6:52 pm by tpham1991
» The Machine that Changed the World: Giant Brains. 1992 Documentary
Sat Dec 08, 2012 2:16 am by ThienDinh
» Problems in practice test.
Thu Dec 06, 2012 2:32 pm by ThienDinh
» Newton's Method
Mon Dec 03, 2012 8:32 pm by ThienDinh
» Console Calc
Sun Dec 02, 2012 5:57 pm by Petahwil
» Law Of Cosines
Sat Dec 01, 2012 4:54 pm by Petahwil