public static void readFromFile(String path) {
String sCurrentLine;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()){
System.out.println("The file in this path ' " + path + " ' exist");
br = new BufferedReader(new FileReader(path));
while ((sCurrentLine = br.readLine()) != null) {
/*String[] result = sCurrentLine.split(",");
for (int x=0; x<result.length; x++)
System.out.println(result[x]);
}*/
System.out.println(sCurrentLine);
}
}
else if (file.createNewFile())
System.out.println("The file " + path + " is created");
else
System.out.println("The file " + path + " can not be created");
}
catch (IOException e) {
e.printStackTrace();
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.