I have found this small code snippet that works just fine:
Lt; String & gt; Line = files.readlines (path. (F.A.A.A.A.O.O.O.O.L.L.L.), Charset.default charset ()); If (lines.size ()> gt;) {char c = lines.get (lines.size () - 1) .charAt (lines.get (lines.size () - 1) .length () - 1); }
but it uses the java.nio package which is not previously Java 1.7
available.
Now I need a reliable way of accomplishing with the former Java versions, do you have any ideas? The only thing I can think of is to read the file line from the line with the BufferedReader
and if the reading is done in any way, it will restore the last character.
(still using Java6 in 2015? Ah)
Here's a solution; Note that it is understood that you already have a BufferedReader
open on file:
string line, finalline = faucet; While ((line = reader. Readline ())! = Null; last line = line; // Get the last character from the last line, as you already do
Note that this will actually return the last (Java) char , which will be the last Can not be the code point .
No comments:
Post a Comment