jarファイルからファイルを読み取り、それをjTextAreaに入れたい場合、実際のコンテンツではなく、暗号化されたシンボルが表示されます。
私がしていること:
public File loadReadme() {
URL url = Main.class.getResource("/readme.txt");
File file = null;
try {
JarURLConnection connection = (JarURLConnection) url
.openConnection();
file = new File(connection.getJarFileURL().toURI());
if (file.exists()) {
this.readme = file;
System.out.println("all ok!");
}
} catch (Exception e) {
System.out.println("not ok");
}
return file;
}
そして、私はファイルを読みました:
public ArrayList<String> readFileToArray(File file) {
ArrayList<String> array = new ArrayList<String>();
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader(file));
while ((sCurrentLine = br.readLine()) != null) {
String test = sCurrentLine;
array.add(test);
}
} catch (IOException e) {
System.out.println("not diese!");
} finally {
try {
if (br != null)
br.close();
} catch (IOException ex) {
}
}
return array;
}
ここで、ArrayListのすべての行をjTextAreaに配置します。これにより、次のように表示されます。
PK����?����^��S?��3���z_��
%�QTl?7��+�;��fK��N��:k����� ]�Xk、������U "�����q��\����%�Q#4x�| [���o�S{��:�aG�*sg� ' 。}���n�X����5��q���hpu�H���W�9���h2��Q����#���@ 7(�@�� ��F!��〜��?����j�?\xA�/�Rr.�v�l�PK�bv�=
textfiledには次のものが含まれます。
SELECTION:
----------
By clicking the CTRL Key and the left mouse button you go in the selection mode.
Now, by moving the mouse, you paint a rectangle on the map.
DOWNLOAD:
---------
By clicking on the download button, you start the download.
The default location for the tiles to download is: <your home>
ファイルが存在すると確信しています!誰かが問題が何であるか知っていますか?私の「getResource」は正しいですか?