Scala, Java, Unix, MacOS tutorials (page 389)

Problem: In a Java program, you want to determine whether a String contains a pattern, you want your search to be case-insensitive, and you want to use String matches method than use the Pattern and Matcher classes.

Solution: Use the String matches method, and include the magic (?i:X) syntax to make your search case-insensitive. (Also, remember that when you use the matches method, your regex pattern must match the entire string.)

Problem: In a Java program, you want to determine whether a String contains a pattern, and you'd rather use the String matches method than use the Pattern and Matcher classes.

Java Matcher problem: You're trying to use the matches method of the Java Matcher class to match a regular expression (regex) you have defined, and it's not working against a given string, and you don't know why.

Problem: In a Java program, you need a way to find/match a pattern against a multiline String or in a more advanced case, you want to extract one or more groups of regular expressions from a multiline String.

Problem: In a Java program, you need a way to extract multiple groups (probably regular expressions) from a given String.

Problem: In a Java program, you want a way to extract a simple HTML tag from a String (and you don't want to use a more complicated approach).

Java pattern problem: In a Java program, you want to determine whether a String contains a regular expression (regex), and then you want to extract the actual group of characters from the String that matches your regex pattern.

Java String FAQ: How can I tell if a Java String contains a given regular expression (regex) pattern?

In a Java program, you want to determine whether a String contains a case-insensitive regular expression (regex). You don't want to manipulate the String or extract the match, you just want to determine whether the pattern exists at least one time in the given String.

Java regex Problem: In a Java program, you want to determine whether a String contains a case-insensitive pattern. The pattern can be a simple String, or a more complicated regular expression (regex).

Problem: In a Java program, you want to determine whether a String contains a certain pattern. The pattern can be a simple String, or a more complicated regular expression (regex).

Summary: A simple Java JScrollPane source code example.

When you're first learning how to use Java Swing components, like a JScrollPane it can be a little hard to figure out how to get started. To that end I am trying to share several complete Java source code examples that demonstrate how to work with components like these.

Java JFrame FAQ: How do I properly create and display a JFrame? While you're at it, how do I center a JFrame?

In this Java tutorial I'll demonstrate how to create and display a JFrame Other than the comments in the source code, I'm going to keep the code as simple as possible, so I can demonstrate how this works.

Did you know that you can use CSS styles when displaying HTML in a Java Swing application? It's pretty cool, and it can help spice up any simple HTML you may currently be showing in a Java-based editor or viewer. In this tutorial I'll share some source code that shows how this works.

I've been working on writing my own Java text editor on and off for several years now, and one feature I just added to this editor is the ability to view (or preview) HTML and CSS content. Using just the base Swing classes this turned out reasonably well -- I'm not looking to write a complete browser here -- so I thought I'd share some source code to show how this works.

On this blog I've shown several examples of how to read content from a URL using Java In this example I'd like to show how you can open a URL and read content from that URL by just using the Java URL class.

Java URL FAQ: Using Java, how can I encode a String that I want to safely pass in a URL to a servlet or CGI program running on a web server?

Summary: This article shares some source code for a Java socket debugging method.

Summary: This article shares the source code for a simple Java Socket client class. This article demonstrates both (a) how to write to a Java socket, and (b) how to read from a Java socket.

Java socket FAQ: How do I set the timeout on a Java socket? That is, when I'm trying to read data from a Java socket, and I'm not getting any response from the server, how do I make sure my code doesn't hang up? (It needs to time out after several seconds.)

Java socket timeout

Answer: Just set the SO_TIMEOUT on your Java Socket, as shown in the following sample code:

Here are a couple of great quotes from two separate articles, one regarding Jack Nicklaus and Tiger Woods, the other about Kobe Bryant.

Jack Nicklaus

From Jack Nicklaus:

"I don't care if I'm playing against my wife, my competitive juices are flowing," Nicklaus said. "That's just me."

Here's another quote from this article: