java - File does not deploying to jar -


I am creating simple application with javaFX inside my project folder that is a text file I use on UI project But when I deploy the jar, there is no text file in it. This file does not exist when I run a jar file in a terminal error. I am not very familiar with making Java UI applications. Below is my code

  BufferedReader = new BufferedReader (new FileReader ("resource / test.txt")); Letter string; & Lt; String & gt; List = New Arrestist & lt; String & gt; (); While ((str = in.readLine ()) = null () {list.add (str); }  

Any help is appreciated,

The problem is facing because you are using FileReader .

FileReader can only be used to read one file directly. If you want to read something inside a jar, try reading it using getResourceAsStream :

  InputStream = getClass (). GetResourceAsStream ("/ resources / test .text"); BufferedReader = New in BufferedReader (New InputStreamReader); ...  

Comments

Popular posts from this blog

c++ - C/pp Sockets, recv()/send() works only under gdb -

GO: Serve static pages -

objective c - How to open front/back camera at the same time in iOS developing? -