Получить файл .jpg из .jar

148
16 августа 2018, 17:00

Пытаюсь получить jpg изображение когда сделал build файл jar, делаю так:

InputStream in = getClass().getClassLoader().getResourceAsStream("/resources/help.jpg");

Сам файл находиться по пути: \src\main\resources\help.jpg

В итоге получаю exception:

Caused by: java.io.FileNotFoundException: file:\C:\Logs\CurrencyConverterBot-1.0.1-RELEASE-jar-with-dependencies.jar!\help.jpg (Синтаксическая ошибка в имени файла, имени папки или метке тома)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:116)
at org.apache.http.entity.mime.AbstractMultipartForm.doWriteTo(AbstractMultipartForm.java:134)
at org.apache.http.entity.mime.AbstractMultipartForm.writeTo(AbstractMultipartForm.java:157)
at org.apache.http.entity.mime.MultipartFormEntity.writeTo(MultipartFormEntity.java:113)
at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:156)
at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:160)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:238)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at org.telegram.telegrambots.bots.DefaultAbsSender.sendHttpPostRequest(DefaultAbsSender.java:720)
at org.telegram.telegrambots.bots.DefaultAbsSender.sendPhoto(DefaultAbsSender.java:212)
... 4 common frames omitted

Подскажите как получить файл jpg из jar в InputStream?

READ ALSO
Как узнать активен ли фрагмент/активити

Как узнать активен ли фрагмент/активити

В андроид приложении нужно реализовать функциональность чатаИнформация о входящем сообщении приходит через Firebase Push и сохраняется в локальной...

184
Java, определение &ldquo;полиморфизм&rdquo;

Java, определение “полиморфизм”

Изучаю JavaПонял что не могу нормально дать определение полиморфизму

150
Синтез речи в Android

Синтез речи в Android

Чем отличается TextToSpeechQUEUE_ADD от TextToSpeech

157
Положение консольного окна на экране

Положение консольного окна на экране

Есть несколько консольных Java приложенийЗапуск приложений производится через *

159