Skip to content

Commit 7461d3d

Browse files
author
Niall Pemberton
committed
IO-121 - Add a reset() method to ThresholdingOutputStream which sets the count of the bytes written back to zero - thanks to Tom Nichols for the patch
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@540644 13f79535-47bb-0310-9956-ffa450edef68
1 parent 4c9e36c commit 7461d3d

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

RELEASE-NOTES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Semantic compatible - ?
2727
Bug fixes from 1.3.2
2828
--------------------
2929

30+
Enhancements from 1.3.2
31+
-----------------------
32+
- ThesholdingOuputStream [IO-121]
33+
- Add a reset() method which sets the count of the bytes written back to zero.
34+
35+
3036
Feedback
3137
--------
3238
Open source works best when you give feedback:

src/java/org/apache/commons/io/output/ThresholdingOutputStream.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,20 @@ protected void checkThreshold(int count) throws IOException
217217
{
218218
if (!thresholdExceeded && (written + count > threshold))
219219
{
220-
thresholdReached();
221220
thresholdExceeded = true;
221+
thresholdReached();
222222
}
223223
}
224224

225+
/**
226+
* Resets the byteCount to zero. You can call this from
227+
* {@link #thresholdReached()} if you want the event to be triggered again.
228+
*/
229+
protected void reset()
230+
{
231+
this.thresholdExceeded = false;
232+
this.written = 0;
233+
}
225234

226235
// ------------------------------------------------------- Abstract methods
227236

0 commit comments

Comments
 (0)