For a variety of reasons you can end up with text files on your Unix filesystem that have binary characters in them. In fact, I showed you how to do this to yourself in my blog post about the Unix script command. (There’s nothing wrong with this approach; it’s just a by-product of using the script command.)
Scala, Java, Unix, MacOS tutorials (page 389)
| A Programming Classic! | |
|
The Pragmatic Programmer |
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.)
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.
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.
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.
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.
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:
| A Programming Classic! | |
|
The Pragmatic Programmer |