home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2026
Discussions: 188,394, Posts: 2,243,574, Members: 232,623
Old January 16th, 2002, 10:49 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
HELLP!!! I can't figure this out.

import java.io.*;
//
class Comparator
{
private static String f1;
private static String f2;
//----------------------------------------------
public Comparator(String f1, String f2)
{
this.f1 = f1;
this.f2 = f2;
}
//----------------------------------------------
public _____ compare()throws Exception
{
BufferedReader br1 = new BufferedReader(
new InputStreamReader(
new FileInputStream(f1)));

String fileOneLine = br1.readLine();
int charNum1 = 0;
int upperCaseNumOne = 0;
while (f1 != null)
{
char fileOne = fileOneLine.charAt(charNum1);
if (Character.isUpperCase(fileOne)) return true;
fileOneLine = br1.readLine();
charNum1++;
}

BufferedReader br2 = new BufferedReader(
new InputStreamReader(
new FileInputStream(f2)));

String fileTwoLine = br2.readLine();
int charNum2 = 0;
int upperCaseNumTwo = 0;
while (f2 != null)
{
char fileTwo = fileTwoLine.charAt(charNum2);
if (Character.isUpperCase(fileTwo)) return true;
fileTwoLine = br2.readLine();
charNum2++;
}

System.out.println(f1 + " has " + upperCaseNumOne + " uppercase letters.");
System.out.println(f2 + " has " + upperCaseNumTwo + " uppercase letters.");
}
//----------------------------------------------
}//End of class Comparator
////////////////////////////////////////////////
//
class Hw02
{
//----------------------------------------------
public static void main(String[] args)throws Exception
{
Comparator a = new Comparator("hw02abc.txt", "hw02xyz.txt");
a.compare();
}
}




//-----------------------

I keep getting a Null Pointer Exception.....and I can't figure out why!!!!!

Tekk is offline   Reply With Quote
Old January 17th, 2002, 06:13 AM     #2 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
Can you repost it using the code tag? It means the indents show up properly. Thanks.

strangerstill is offline   Reply With Quote
Old January 17th, 2002, 06:19 AM     #3 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
This doesn't look right
Code:
if (Character.isUpperCase(fileOne)) return true;
It should be
Code:
if (Character.isUpperCase(fileOne)) upperCaseNumOne++;

strangerstill is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2904)
Building a gaming computer advice (5)
New Build ( Finally ) (6)
Looks like Burris will get his Sena.. (12)
CPU wont boot (7)
3-days in and no threads about Gaza (160)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (444)
Upgrading RAM (6)
Recent Discussions
building a gaming computer, inp.. (0)
Iming and surfing slowed down (3)
Laptop proccesor to desktop mob.. (0)
Please help! multiple problems! (3)
Left 4 Dead Small Freezes (1)
Install Problem for Windows Def.. (1)
RCA 52Inch HDTV wont turn on (2)
nVidia GTX 295 now available (1)
Error ~ BAD BLOCK (19)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 01:55 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28