import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
public class test {
public static void main(String[] args){
try {
File fileDir = new File("c:\\temp\\test.txt");
BufferedReader in = new BufferedReader(
new InputStreamReader(
new FileInputStream(fileDir), "UTF8"));
String str;
while ((str = in.readLine()) != null) {
System.out.println(str);
}
in.close();
}
catch (UnsupportedEncodingException e)
{
System.out.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
private String getStringFromInputStream(InputStream inputStream) {
final int bufferSize = 1024;
final char[] buffer = new char[bufferSize];
final StringBuilder out = new StringBuilder();
Reader in = null;
try {
in = new InputStreamReader(inputStream, "UTF-8");
for (; ; ) {
int rsz = in.read(buffer, 0, buffer.length);
if (rsz < 0)
break;
out.append(buffer, 0, rsz);
}
} catch (IOException e) {
e.printStackTrace();
}
return out.toString();
}
...
HttpEntity entityGet = response.getEntity();
tempSourceFile = getStringFromInputStream(response.getEntity().getContent());
...
<Button fx:id="refreshButton" mnemonicParsing="false"
onAction="#handleButtonRefreshStatsAction" prefHeight="34.0"
text="Refresh stats"/>
@FXML
Button refreshButton = new Button();
@FXML
private void handleButtonRefreshStatsAction(ActionEvent event) {
LOGGER.info("Pressed button Refresh Stats");
Platform.runLater(new Runnable() {
@Override
public void run() {
new Thread(new Runnable() {
@Override
public void run() {
//DO SOMETHING HERE
}
}).start();
}
});
}