Fix comment.
This commit is contained in:
parent
18fb286df9
commit
b85fa4a937
1 changed files with 28 additions and 29 deletions
|
@ -13,10 +13,9 @@ import java.io.PrintWriter;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@author christian.momon@devinsy.fr, June 2008, copyright.
|
||||
@author christian.momon@devinsy.fr, 2008-2013 copyright.
|
||||
*
|
||||
* This file is free software under the terms of the GNU Library General
|
||||
* Public License as published by the Free Software Foundation version 3
|
||||
|
@ -37,7 +36,7 @@ public class FileTools
|
|||
public static File addToName(final File file, final String addition)
|
||||
{
|
||||
File result;
|
||||
|
||||
|
||||
if (file == null)
|
||||
{
|
||||
result = null;
|
||||
|
@ -51,7 +50,7 @@ public class FileTools
|
|||
//
|
||||
String sourceFileName = file.getAbsolutePath();
|
||||
int separatorIndex = sourceFileName.lastIndexOf('.');
|
||||
|
||||
|
||||
//
|
||||
String targetFileName;
|
||||
if (separatorIndex > 0)
|
||||
|
@ -62,11 +61,11 @@ public class FileTools
|
|||
{
|
||||
targetFileName = sourceFileName + addition;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
result = new File(targetFileName);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ public class FileTools
|
|||
public static String getExtension(final File file)
|
||||
{
|
||||
String result;
|
||||
|
||||
|
||||
if (file == null)
|
||||
{
|
||||
result = null;
|
||||
|
@ -99,7 +98,7 @@ public class FileTools
|
|||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -113,10 +112,10 @@ public class FileTools
|
|||
static public String load(final File source) throws IOException
|
||||
{
|
||||
String result;
|
||||
|
||||
|
||||
final String DEFAULT_CHARSET_NAME = "UTF-8";
|
||||
result = load(source, DEFAULT_CHARSET_NAME);
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -129,9 +128,9 @@ public class FileTools
|
|||
public static String load(final File source, final String charsetName) throws IOException
|
||||
{
|
||||
String result;
|
||||
|
||||
|
||||
result = loadToStringBuffer(source, charsetName).toString();
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -145,10 +144,10 @@ public class FileTools
|
|||
static public String load(final URL source) throws IOException
|
||||
{
|
||||
String result;
|
||||
|
||||
|
||||
final String DEFAULT_CHARSET_NAME = "UTF-8";
|
||||
result = load(source, DEFAULT_CHARSET_NAME);
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -161,14 +160,14 @@ public class FileTools
|
|||
public static String load(final URL source, final String charsetName) throws IOException
|
||||
{
|
||||
String result;
|
||||
|
||||
|
||||
//
|
||||
StringBuffer buffer = new StringBuffer(source.openConnection().getContentLength() + 1);
|
||||
read(buffer, source.openStream(), charsetName);
|
||||
|
||||
|
||||
//
|
||||
result = buffer.toString();
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -181,19 +180,19 @@ public class FileTools
|
|||
public static StringBuffer loadToStringBuffer(final File file, final String charsetName) throws IOException
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
|
||||
BufferedReader in = null;
|
||||
try
|
||||
{
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
|
||||
|
||||
|
||||
boolean ended = false;
|
||||
final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
result = new StringBuffer((int) file.length() + 1);
|
||||
while (!ended)
|
||||
{
|
||||
String line = in.readLine();
|
||||
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
ended = true;
|
||||
|
@ -218,7 +217,7 @@ public class FileTools
|
|||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
@ -234,14 +233,14 @@ public class FileTools
|
|||
try
|
||||
{
|
||||
in = new BufferedReader(new InputStreamReader(is, charsetName));
|
||||
|
||||
|
||||
boolean ended = false;
|
||||
final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
|
||||
while (!ended)
|
||||
{
|
||||
String line = in.readLine();
|
||||
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
ended = true;
|
||||
|
@ -280,7 +279,7 @@ public class FileTools
|
|||
try
|
||||
{
|
||||
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
|
||||
|
||||
|
||||
out.println(string);
|
||||
}
|
||||
finally
|
||||
|
@ -301,7 +300,7 @@ public class FileTools
|
|||
public static File setExtension(final File source, final String extension)
|
||||
{
|
||||
File result;
|
||||
|
||||
|
||||
if ((source == null) || (extension == null))
|
||||
{
|
||||
result = source;
|
||||
|
@ -310,7 +309,7 @@ public class FileTools
|
|||
{
|
||||
String sourceFileName = source.getAbsolutePath();
|
||||
int separatorIndex = sourceFileName.lastIndexOf('.');
|
||||
|
||||
|
||||
//
|
||||
String targetFileName;
|
||||
if (separatorIndex > 0)
|
||||
|
@ -321,11 +320,11 @@ public class FileTools
|
|||
{
|
||||
targetFileName = sourceFileName + extension;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
result = new File(targetFileName);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue