Java Utililty Methods File Object Create

List of utility methods to do File Object Create

Description

The list of methods to do File Object Create are organized into topic(s).

Method

FiletoFile(String inFile)
to File
return toFile(inFile, true, true);
StringtoFile(String line)
to File
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StringBuilder sb = new StringBuilder();
for (char c : line.toLowerCase().toCharArray()) {
    String s = String.valueOf(c);
    if (" ".equals(s)) {
        sb.append("/");
        sleep(bos, 7 * 8);
    } else if (morseAlphabet.containsKey(s)) {
...
FiletoFile(String path)
Convert Git path to a relative File
return new File(path.replace('/', File.separatorChar));
FiletoFile(String path)
to File
if (File.separatorChar == '/') {
    return new File(path.replace('\\', '/'));
} else {
    return new File(path.replace('/', '\\'));
FiletoFile(String path)
Like new File(path) EXCEPT this will convert Windows/Max/Linux separators into the local format.
if (path == null)
    return null;
if (File.separatorChar == '\\') {
    return new File(path.replace('/', File.separatorChar));
} else {
    return new File(path.replace('\\', File.separatorChar));
FiletoFile(String path)
to File
String baseDir = System.getProperty(PARAM_CLASSPATH_BASE);
if (baseDir != null) {
    return new File(baseDir, path);
return new File(path);
FiletoFile(String path)
create a file from path
return new File(path.replace(FILE_ANTI_SEPERATOR, FILE_SEPERATOR));
voidtoFile(String path, String toWrite)
to File
try {
    File file = new File(path);
    if (!file.exists()) {
        file.createNewFile();
    FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(toWrite);
...
FiletoFile(String s)
to File
if (s == null) {
    return null;
} else {
    return new File(s.replace('\\', File.separatorChar).replace('/', File.separatorChar));