Someone please correct my code so that my program reads the comma seperated text file line by line and
checks for a specific data(swf or image) in a 6th column and (Questions) in the 2nd column.
package readingFromTextFile;
import java.io.BufferedReader;
import java.io.FileReader;
public class MainClass
{
public static void main(String args[])
{
try
{
FileReader fr=null;
BufferedReader br = new BufferedReader(new FileReader("test.txt"));
String s;
while((s = br.readLine()) != null)
{
String[] tkn =s.split(",",-1);
for(int i=0; i<tkn.length;i++)
{
System.out.println(tkn);
/*if(tkn[6]=="application/x-shockwave-flash")
{
System.out.println("SWF file found ");
}
if(tkn[6]=="image/jpeg")
{
System.out.println("Image file found ");
}
if(tkn[2]=="Questions")
{
System.out.println("Questions found");
}
else
{
System.out.println("Other type of slides found");
}*/
}
}
fr.close();
}
catch(Exception e)
{
System.out.println("Exception: " + e);
}
}
}
*the above code prints the output in the following format*
//Output:
AAAAA
1111111
2222222
http:test.html
application/x-url
222222
XXXXXXXXXX
Image
599204
483580
483579/media.jpg
image/jpeg
795
My file
Code
8
9
sample.swf
application/x-shockwave-flash
1296
stamps
New Polling
4863