I am developing a project that converts SQL server file to MySQL file based on some assumptions. I have written a function that takes the string source as input and it extracts the database name. Is there any way to improve the code?
public String getDatabaseNameFromMySqlServerFile(String source) {
String sourceFile = null;
String databaseName = "";
Path file = Paths.get(source);
try (InputStream in = Files.newInputStream(file);
BufferedReader reader
= new BufferedReader(new InputStreamReader(in))) {
String line = null;
while ((line = reader.readLine()) != null) {
if (line.toLowerCase().contains("create database")) {
String[] Arrline = line.split(" ");
for (String s : Arrline) {
if (!s.toLowerCase().equals("create") && !s.toLowerCase().equals("database")) {
databaseName = s;
return s;
}
}
}
sourceFile = sourceFile + line;
}
} catch (IOException x) {
System.err.println(x);
}
return null;
}