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