Click here to Skip to main content
       

Java

 
GeneralRe: JCOMBOBOX PinmvpRichard MacCutchan4-Dec-12 7:24 
Questionneed help Pinmemberdipfol29-Nov-12 17:56 
AnswerRe: need help PinmemberAprNgp29-Nov-12 20:08 
AnswerRe: need help PinmvpRichard MacCutchan29-Nov-12 21:51 
Questionextract battery percentage Pinmemberakki23099127-Nov-12 20:55 
AnswerRe: extract battery percentage PinmvpRichard MacCutchan27-Nov-12 23:59 
Questioni have a problem around System.console, am using eclipse PinmemberMember 963455227-Nov-12 0:31 
AnswerRe: i have a problem around System.console, am using eclipse PinmemberTorstenH.27-Nov-12 1:44 
I don't know where you got that console hassle there - it's a complete mixup.
 
Your code works when the console is addressed right:
 
public class RegexTestHarness {
 
	public static void main(String[] args) {
		while (true) {
			try {
				BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); // only this can provide a buffered reading
				System.out.println("Enter your regex:");
				String strValue = console.readLine(); // read value
				Pattern pattern = Pattern.compile(strValue); // create pattern
			
				System.out.println("Enter input string to search:");
				String strMatch = console.readLine();
				Matcher matcher = pattern.matcher(strMatch);
	
				boolean found = false;
				while (matcher.find()) {
					System.out.println(String.format("I found the text" + " \"%s\" starting at "
							+ "index %d and ending at index %d.",
							matcher.group(), matcher.start(), matcher.end()));
					found = true;
				}
				if (!found) {
					System.console().format("No match found.");
				}
			} catch (IOException oException) { oException.printStackTrace();} // for the buffered reader - in case it fails
		}
	}
}
regards Torsten
When I'm not working

GeneralRe: i have a problem around System.console, am using eclipse PinmemberMember 963455228-Nov-12 2:00 
GeneralRe: i have a problem around System.console, am using eclipse PinmemberTorstenH.28-Nov-12 8:36 
GeneralRe: i have a problem around System.console, am using eclipse PinmemberMember 963455228-Nov-12 23:43 
GeneralRe: patient cancer registration form PinmemberMember 963455215-Jan-13 2:44 
GeneralRe: patient cancer registration form PinmemberTorstenH.15-Jan-13 3:33 
QuestionMobile in java using netbeans Pinmemberrcjr2421-Nov-12 13:36 
SuggestionRe: Mobile in java using netbeans PinmvpRichard MacCutchan21-Nov-12 22:05 
Questionhi i need help about RIM,client server,file sharing Pinmembershado-ite21-Nov-12 8:47 
AnswerRe: hi i need help about RIM,client server,file sharing PinmvpRichard MacCutchan21-Nov-12 8:58 
QuestionMail server in java PinmemberMember 954244521-Nov-12 2:23 
AnswerRe: Mail server in java PinmvpRichard MacCutchan21-Nov-12 3:14 
AnswerRe: Mail server in java PinmemberTorstenH.24-Nov-12 5:38 
QuestionUsing MuPDF library in java PinmemberMember 960666216-Nov-12 22:40 
AnswerRe: Using MuPDF library in java PinmvpRichard MacCutchan17-Nov-12 21:58 
AnswerRe: Using MuPDF library in java Pinmemberyangxiaoyan18-Nov-12 16:58 
Questionuse snmp check equiment type PinmemberXMafei13-Nov-12 22:05 
AnswerRe: use snmp check equiment type PinmemberTorstenH.14-Nov-12 19:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 12 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid