Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Split string with backslash regex

807599Nov 14 2006 — edited Nov 14 2006
Hi,

I'm having a problem with splitting a string with backslash. This code below is giving me the error "Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1". Please assist. Thank you.
import java.io.*;

public class TestRegex
{
	public static void main ( String args[] )
	{
		String testFilePath = new File( "" ).getAbsolutePath();
		
		System.out.println( testFilePath );
		
		File tempFile = new File( testFilePath );
		
		String[] getFolder = testFilePath.split( "\\" ); // changing to other will work
		
		for( int i = 0; i < getFolder.length; i++ )
		{
			System.out.println( getFolder[ i ] );
		}
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2006
Added on Nov 14 2006
2 comments
1,699 views