A file filter question

M

mikeotp

regards:
------------------------------------------------------------------
public FileOutputStream doFunction(FileInputStream file1) {

<--codes to filter some specific characters or String in file1-->

<--
example following:
characters:a
String:<test>
-->


}

FileOutputStrea is different from FileInputStream
by some specific characters or String.


------------------------------------------------------------------
How can I compose my code?^^
Any suggestions is welcome.

Thank you.
May god be with you.
 
T

The Abrasive Sponge

mikeotp wrote:

Thank you.
May god be with you.

Can I help even though I am agnostic?

public class MyFilter extends FilterReader {
//method removes all 'a' characters
public int read() {
char c = super.read();
if (c == 'a') {
return this.read();
}
}

}

I haven't compiled this...but clean it up, compile and attach it to a
FileReader and give it a try.
 
T

The Abrasive Sponge

The said:
mikeotp wrote:




Can I help even though I am agnostic?

public class MyFilter extends FilterReader {
//method removes all 'a' characters
public int read() {
char c = super.read();
if (c == 'a') {
return this.read();
}
}

}

I haven't compiled this...but clean it up, compile and attach it to a
FileReader and give it a try.

public class MyFilter extends FilterReader {
//method removes all 'a' characters
public int read() {
char c = super.read();
if (c == 'a') {
return this.read();
} else {
return c; //Correction
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top