To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


EIT Planet's Security News
 Microsoft Warns of Decades Old Windows Bug
 Microsoft Says No Hole in IIS 6
 Privacy on the Internet: What to Watch for in 2010

Security Products
 bio-iVault Biometric Encrypted Virtual Drive (Cordian Corp)
 PortableSafe (Boydevlin Ltd)
 Excel Password Recovery Master (Rixler Software)
 Evidence Eraser (Tried Tool)
 Access Password Recovery Software (Access Password Recovery)
 Ainishare Exe Lock (Ainishare Software)


Go Back   Antionline Forums - Maximum Security for a Connected World > General Technology Forums > Code Review

Code Review Antionline community members can use this section of the site to post code for sharing and testing.

Reply
 
Thread Tools Search this Thread Display Modes
Old October 10th, 2004, 07:25 AM   #1
harbir
Senior Member
 
Join Date: Dec 2001
Posts: 134
harbir can only hope to improve
Java Problem!!!

I have a question in Java. I am new to this language and i have a big(i think for me it is big) problem.

If i have a text file with a data record similar to the two lines of text shown below.

10000001 01.11.199600.00.000001 A1 1 SN
2001.11.200300096.0500072.0500081.65


and i want to pick up all the records whose first two digits are 10 (as
shown in the first example), what's the best way to do this ?

Cause its not possible to manually put a delimiter after the first two
digits in every single record and then scan the file for the first two
desired digits.
I want to know about the Java File handling mechanism.

Please reply.

Thank you very much.
__________________
U get What U pay for.
harbir is offline   Reply With Quote
Old October 10th, 2004, 05:26 PM   #2
groovicus
Senior Member
 
Join Date: Aug 2003
Posts: 1,019
groovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond reputegroovicus has a reputation beyond repute
In Psuedocode, it would be something like this (if I am understanding what you are trying to do)

loop:
Get fileName as a string.
create a new String s = fileName.substring(0,2).
see if s.matches ("[1][0]").
if it matches, then do action based on finding a valid filename.

Or you could do it this way:
Get fileName as a string.
Loop from 0 to 1
See if charat(0) is a 1, if true, then see if charat(1) is a 0.
If the chars match, then do action based on valid file name.

Does that help any??
__________________
HijackThis Team
groovicus is offline   Reply With Quote
Old October 11th, 2004, 09:19 PM   #3
BigDick
Member
 
Join Date: Oct 2004
Posts: 40
BigDick is on a distinguished road
I would use the regular expressions package, java.util.regex, construct a regular expression that matches the pattern of what you are looking for, then you split the results using a pattern.split() call and you have everything you need. For a full explanation of the java.util.regex package you can get it from the online api at http://java.sun.com/j2se/1.4.2/docs/api/index.html
__________________
--BigDick


\"When in Rome, eat Rome!\" -Godzilla
BigDick is offline   Reply With Quote
Old October 11th, 2004, 09:20 PM   #4
BigDick
Member
 
Join Date: Oct 2004
Posts: 40
BigDick is on a distinguished road
I should have been more clear before, this package will do all of the work of a char at and all that and at the same time give you something that can possibly be reused.

-BigDick
__________________
--BigDick


\"When in Rome, eat Rome!\" -Godzilla
BigDick is offline   Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:00 PM.












Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.