Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/java/org/apache/commons/io/FileSystemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,15 @@ long freeSpaceOS(final String path, final int os, final boolean kb, final long t
* @param timeout The timeout amount in milliseconds or no timeout if the value
* is zero or less
* @return the amount of free drive space on the drive
* @throws IOException if an error occurs
* @throws IOException if an error occurs, NullPointerException if path cannot be parsed by FilenameUtils.normalize()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a separate throws declaration

*/
long freeSpaceWindows(String path, final long timeout) throws IOException {
long freeSpaceWindows(String path, final long timeout) throws IOException, NullPointerException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NullPointerException is a RuntimeException so it should be part of the method signature.

path = FilenameUtils.normalize(path, false);

if(path == null)
throw new NullPointerException(
"The path cannot be parsed by FilenameUtils.normalize().");

if (path.length() > 0 && path.charAt(0) != '"') {
path = "\"" + path + "\"";
}
Expand Down
48 changes: 24 additions & 24 deletions src/main/java/org/apache/commons/io/serialization/package.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<body>
<p>
This package provides a framework for controlling the deserialization of classes.
</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<body>
<p>
This package provides a framework for controlling the deserialization of classes.
</p>
</body>
</html>
122 changes: 61 additions & 61 deletions src/site/xdoc/upgradeto2_3.xml
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document>
<properties>
<title>Upgrade from 2.2 to 2.3</title>
<author email="dev@commons.apache.org">Commons Documentation Team</author>
</properties>
<body>
<section name="Upgrade">
<p>
These are the release notes and advice for upgrading Commons-IO from
version 2.2 to version 2.3
<source>
Commons IO is a package of Java utility classes like java.io.
Classes in this package are considered to be so standard and of such high
reuse as to justify existence in java.io.
The Commons IO library contains utility classes, stream implementations, file filters,
file comparators, endian transformation classes, and much more.
==============================================================================
Apache Commons IO Version 2.3-SNAPSHOT
==============================================================================
Changes in this version include:
New features:
o IO-322: Add and use class Charsets. Thanks to ggregory.
o IO-321: ByteOrderMark UTF_32LE is incorrect. Thanks to ggregory.
o IO-318: Add Charset sister APIs to method that take a String charset name. Thanks to ggregory.
Compatibility with 2.2 and 1.4:
Binary compatible: Yes.
Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Commons IO 2.3 requires JDK 1.6 or later.
Commons IO 2.2 requires JDK 1.5 or later.
Commons IO 1.4 requires JDK 1.3 or later.
</source>
</p>
</section>
</body>
</document>
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document>
<properties>
<title>Upgrade from 2.2 to 2.3</title>
<author email="dev@commons.apache.org">Commons Documentation Team</author>
</properties>
<body>

<section name="Upgrade">
<p>
These are the release notes and advice for upgrading Commons-IO from
version 2.2 to version 2.3
<source>
Commons IO is a package of Java utility classes like java.io.
Classes in this package are considered to be so standard and of such high
reuse as to justify existence in java.io.

The Commons IO library contains utility classes, stream implementations, file filters,
file comparators, endian transformation classes, and much more.

==============================================================================
Apache Commons IO Version 2.3-SNAPSHOT
==============================================================================

Changes in this version include:

New features:
o IO-322: Add and use class Charsets. Thanks to ggregory.
o IO-321: ByteOrderMark UTF_32LE is incorrect. Thanks to ggregory.
o IO-318: Add Charset sister APIs to method that take a String charset name. Thanks to ggregory.

Compatibility with 2.2 and 1.4:
Binary compatible: Yes.
Source compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.
Semantic compatible: No, see the rare case in https://issues.apache.org/jira/browse/IO-318.

Commons IO 2.3 requires JDK 1.6 or later.
Commons IO 2.2 requires JDK 1.5 or later.
Commons IO 1.4 requires JDK 1.3 or later.
</source>
</p>
</section>

</body>
</document>
18 changes: 18 additions & 0 deletions src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,22 @@ public void destroy() {
}
}

@Test(expected = NullPointerException.class)
public void testGetFreeSpaceWindows_String_InvalidPath() throws Exception {
final String lines =
" Volume in drive C is HDD\n" +
" Volume Serial Number is XXXX-YYYY\n" +
"\n" +
" Directory of C:\\Documents and Settings\\Xxxx\n" +
"\n" +
"19/08/2005 22:43 <DIR> .\n" +
"19/08/2005 22:43 <DIR> ..\n" +
"11/08/2005 01:07 81 build.properties\n" +
"17/08/2005 21:44 <DIR> Desktop\n" +
" 7 File(s) 180260 bytes\n" +
" 10 Dir(s) 41411551232 bytes free";
final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\"");
fsu.freeSpaceWindows("..", -1);
}

}
13 changes: 13 additions & 0 deletions src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,17 @@ public void testCopy_readerToWriter_IO84() throws Exception {

}

// @Test
// public void MorphisZhang() throws Exception {
// InputStream in = new ByteArrayInputStream(inData);
// in = new YellOnCloseInputStream(in);
// final Reader reader = new InputStreamReader(in, "US-ASCII");

// final ByteArrayOutputStream baout = new ByteArrayOutputStream();
// final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
// out.flush();
// out.close();
// IOUtils.copy(reader, out, "UTF16");
// }

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1
2
3
1
2
3
4 changes: 2 additions & 2 deletions src/test/resources/test-file-gbk.bin
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
��ݔ�Ӿ�
��������
��ݔ�Ӿ�
��������
24 changes: 12 additions & 12 deletions src/test/resources/test-file-iso8859-1-shortlines-win-linebr.bin
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
1
2
3
1



2



3



104 changes: 52 additions & 52 deletions src/test/resources/test-file-utf8-win-linebr.bin
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²®
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©
A Test Line. Special chars: ÄäÜüÖöß ÃáéíïçñÂ
A Test Line. Special chars: ÄäÜüÖöß ÃáéíïçñÂ
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïç
A Test Line. Special chars: ÄäÜüÖöß Ãáéíï
A Test Line. Special chars: ÄäÜüÖöß Ãáéí
A Test Line. Special chars: ÄäÜüÖöß Ãáé
A Test Line. Special chars: ÄäÜüÖöß Ãá
A Test Line. Special chars: ÄäÜüÖöß Ã
A Test Line. Special chars: ÄäÜüÖöß
A Test Line. Special chars: ÄäÜüÖöß
A Test Line. Special chars: ÄäÜüÖö
A Test Line. Special chars: ÄäÜüÖ
A Test Line. Special chars: ÄäÜü
A Test Line. Special chars: ÄäÜ
A Test Line. Special chars: Ää
A Test Line. Special chars: Ä
A Test Line. Special chars:
A Test Line. Special chars:
A Test Line. Special chars
A Test Line. Special char
A Test Line. Special cha
A Test Line. Special ch
A Test Line. Special c
A Test Line. Special
A Test Line. Special
A Test Line. Specia
A Test Line. Speci
A Test Line. Spec
A Test Line. Spe
A Test Line. Sp
A Test Line. S
A Test Line.
A Test Line.
A Test Line
A Test Lin
A Test Li
A Test L
A Test
A Test
A Tes
A Te
A T
A
A
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²®
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©
A Test Line. Special chars: ÄäÜüÖöß ÃáéíïçñÂ
A Test Line. Special chars: ÄäÜüÖöß ÃáéíïçñÂ
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ
A Test Line. Special chars: ÄäÜüÖöß Ãáéíïç
A Test Line. Special chars: ÄäÜüÖöß Ãáéíï
A Test Line. Special chars: ÄäÜüÖöß Ãáéí
A Test Line. Special chars: ÄäÜüÖöß Ãáé
A Test Line. Special chars: ÄäÜüÖöß Ãá
A Test Line. Special chars: ÄäÜüÖöß Ã
A Test Line. Special chars: ÄäÜüÖöß
A Test Line. Special chars: ÄäÜüÖöß
A Test Line. Special chars: ÄäÜüÖö
A Test Line. Special chars: ÄäÜüÖ
A Test Line. Special chars: ÄäÜü
A Test Line. Special chars: ÄäÜ
A Test Line. Special chars: Ää
A Test Line. Special chars: Ä
A Test Line. Special chars:
A Test Line. Special chars:
A Test Line. Special chars
A Test Line. Special char
A Test Line. Special cha
A Test Line. Special ch
A Test Line. Special c
A Test Line. Special
A Test Line. Special
A Test Line. Specia
A Test Line. Speci
A Test Line. Spec
A Test Line. Spe
A Test Line. Sp
A Test Line. S
A Test Line.
A Test Line.
A Test Line
A Test Lin
A Test Li
A Test L
A Test
A Test
A Tes
A Te
A T
A
A
4 changes: 2 additions & 2 deletions src/test/resources/test-file-windows-31j.bin
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
����������
���A�q��
����������
���A�q��
4 changes: 2 additions & 2 deletions src/test/resources/test-file-x-windows-949.bin
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
�ѱ���
���ѹα�
�ѱ���
���ѹα�
4 changes: 2 additions & 2 deletions src/test/resources/test-file-x-windows-950.bin
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
����l��
�c�餤��
����l��
�c�餤��