cancel
Showing results for 
Search instead for 
Did you mean: 

java code

Former Member
0 Kudos

BufferedReader in = new BufferredReader(new InputStreamReader(inStream));

BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream));

Pattern P = Pattern.compile("\032");

Matcher m = p.matcher("");

Hi

I have above piece of code. The purpose of the code is to remove the special characters when they come in input file.

Like to understand what the above lines of code do actually ?? Any java+XI experts plz help me

I am using the below packages

import java.util.regex.Matcher;

import java.util.regex.Pattern;

thanks

kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

It is checking the Pattern type and Matcher type. If you want to more about these classes what exactly the methods will do you can find in Java1.4 API search for java.util.Pattern and java.util.Matcher else if java installed in your machine.

run this command in command prompt

javap java.util.Pattern it will display all the methods with simple description. It's helpful for you to know about the methods functionality.

Thanks,

RamuV

Former Member
0 Kudos

Hi

Could you plz explain the pattern meaning of ("\032") ?? Whether it is simply thrity two or it has some meaning of octagonal or hexagonal character values ?? For which pattern it will search ?? I believe that code is for special characters and not for simply thirty two. Plz advise.

Former Member
0 Kudos

Hi,

"\032" is the decimal conversion for SPACE in ascii . Please refer to the link below for decimal to ascii units.

http://faculty.tp.devry.edu/~yhuh/ascii.htm

Thanks

Amit

Reward points if suggestion is useful

Answers (3)

Answers (3)

GabrielSagaya
Active Contributor
0 Kudos

Hi,

This code is used in java mapping to identify the special character and remove it (CTRL+Z)

http://www.java2s.com/Code/Java/Regular-Expressions/Patterncompile.htm

http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html

ftp://kermit.columbia.edu/kermit/b/k11ins.doc

Former Member
0 Kudos

Hi,

You are importing Regular Expressions package using which you might want to findout a particular pattern when it occurs in the file, and you might want to take some action when it found.

But in the code given above, you didn't show that you are dealing with the input file. But you tried to find a particular pattern match.

Regards

Bhanu.

Former Member
0 Kudos

Hi

This is not the complete code, you are not using in and out anywhere in the code. you have just read the file in the form of input stream at first line, opened an output stream at the second line, matching the pattern space in the next line and removing the same in the last line. I hope it clarifies your question.

Thanks

Amit

Reward points if answer is useful

Former Member
0 Kudos

Hi

This is not the full code. But the idea behind the actual code could be to identify a space character and remove the same.

Sameer