Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2008, 04:10 AM
Member
 
Join Date: Feb 2008
Posts: 2
Java_Man is on a distinguished road
Here is my code, can anyone here help me?
import java.util.Scanner;
import java.lang.*;



public class ByteMonitor {

public ByteMonitor() {
}

public static void main(String[] args) {

Scanner scanner = null;

try {
scanner = new Scanner(new File("my_file.dat")); }
catch (FileNotFound ex) {
ex.printStackTrace(); }

Pattern file = Pattern.compile("x");
Matcher mfile = file.matcher("1001x000");
Matcher mfile = file.matcher("11111011");
Matcher m_2_file = file.matcher("00x00000");
Matcher m_3_file = file.matcher("00000000");
Matcher m_4_file = file.matcher("1001000x");
boolean x0 = mfile.matches();
boolean x1 = m1file.matches();
boolean x2 = m2file.matches();
boolean x3 = m3file.matches();
boolean x4 = m4file.matches();


System.out.println(scanner.nextLine());
}
}

-----------

I'm trying to get the result to print out this...

x
null
x
null
x

so if anyone here can edit and help me what I did wrong and fix my code, I would greatly appreciate it, thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-16-2008, 04:41 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
When posting source code, use the code tags available in the post Reply page. Or "[ code]" to start code and "[ /code]" to end code. This presents your code in more easily viewable way.

Quote:
Originally Posted by Java_Man View Post
import java.util.Scanner;
import java.lang.*;
The java.lang is imported by default- this is the base of the Java language. Thus you don't need it. But you're missing an import for some of the classes you're using. For example, where do you find Pattern and Matcher? Go to the API and look if you do not know. While you're there, please tell me where you find the exception "FileNotFound". On this one, I'll be easier- the correct name is "FileNotFoundException". See the difference?

Quote:
I'm trying to get the result to print out this...

x
null
x
null
x
Well, what does your my_file.dat have in it?

Quote:
so if anyone here can edit and help me what I did wrong and fix my code, I would greatly appreciate it, thanks.
No. The problem you're having is syntactic in nature. We're not here to "fix" your code- the majority of us are here to assist you with your Java programming issues. I spoke briefly of the issues you're currently having, now get to it. If it doesn't compile after you've attempted it, come back and post your updated code again(with code tags).
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help fixing my code.. or non code? MrHuggykins New To Java 1 03-20-2008 12:12 AM
Pls some one to help mi wit this code _nik_ New To Java 3 02-10-2008 04:02 AM
tic tac toe code zoe New To Java 1 07-23-2007 06:36 PM
Need help with my code. stormviper New To Java 0 07-12-2007 05:18 PM
Generating Code Automatically Using Custom code Template In Eclipse JavaForums Eclipse 1 04-26-2007 05:52 PM


All times are GMT +3. The time now is 09:34 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org