java


Unexpected token END OF FILE at position 8192 (not at position 0)


I am working on this project where I get Json responses and turn them in to objects of type shop. A requirement is to make a jar file of the project and insert it in to another project that will create a File out of those objects. So far so good. The problems start here:
public static void main(String[] args) throws IOException, Exception {
/* Propertiess practise = new Propertiess();
practise.InitializeConfigParameters();
practise.Print();*/
ArrayList<Shop> ArrayofShops = new ArrayList<>
(YelpJsonApi.SearchForShops("Burgers", "San Francisco"));
}
When I run main from the first project eveything runs perfect, but when I run the same main from my second project this error occures:
Exception in thread "main" Unexpected token END OF FILE at position 8192.
at org.json.simple.parser.JSONParser.parse(Unknown Source)
at org.json.simple.parser.JSONParser.parse(Unknown Source)
at Basics.YelpJsonApi.SearchForShops(YelpJsonApi.java:53)
at Storage.Demo.main(Demo.java:21)
Java Result: 1
This error points to this part:
public class YelpJsonApi {
private static final String USER_AGENT = "Mozilla/5.0";
private static final File shops = new File("C:\\Users\\Stathis\\Documents\\shops.txt");
public static ArrayList<Shop> SearchForShops(String CityName, String Category) throws IOException, Exception{
String url = "someLink" + Category + "&location=" + CityName;
Document doc = Jsoup.connect(url)
.userAgent(USER_AGENT)
.header("Authorization", "someText")
.ignoreContentType(true)
.get();
String responseText = doc.text();
//System.out.println("TEXT:" + responseText);
System.out.println("**************************************************");
JSONParser parser = new JSONParser();
File shops = new File("shops.txt");
ArrayList<Shop> shopListFromApi = new ArrayList<>();
try {
// Object obj = parser.parse(new FileReader(shops));
FileWriter fw = new FileWriter(shops);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(responseText);
JSONObject jsonObject = (JSONObject) parser.parse(new FileReader(shops));
StringReader rT = new StringReader(responseText); // διαφορετικά η από κάτω γραμμή θα πετάει error String cannot be converted to reader
jsonObject = (JSONObject) parser.parse(rT);
...
}
even though I have read most articles at stackoverflow (and other sites) and also have tried most options the error won't seem to get away. I have a suspicion that there might be some problem with my file (even though I have tried storing my info to other files) since the EOF exception is at position 8192 and not at the begining.
Thank you in advance!

Related Links

java file reading: not reading(displaying whole file)
Why does my Oval not print to the JFrame? [duplicate]
Pack h* equivalent in Java
Auto increment ID on a Swing form resets every time the application is launched
Converting .java in to .class without Compiling
client can't connect to server in chat application
Print all paths in a BST in java
java.lang.IllegalArgumentException: sortOrder not supported
How to make new lines in Buffer Writer - Java
Multithreading: passing instance and local variables to a thread
How to read php echo from server via java without getting javascript needed page?
Java: Thread safety of passing value to inner class
Making more variables with variables
Java if string in variable
How to set two classpaths for java in “.bashrc” file?
How can I add any set of Java Number objects, getting the most accurate result?

Categories

HOME
maven
listview
deezer
google-api-php-client
plone
sqlite3
ip
convolution
upload
google-translate
volttron
jplayer
hex-editors
libtiff
saxon
viewport
errorlevel
telerik-reporting
mmap
zurb-foundation-6
trading
xpages-ssjs
apache-commons-io
chromebook
virtualdub
traffic
saas
tinymce-4
bosh
semantic-versioning
create-table
jspresso
uiswipegesturerecognizer
http-referer
amazon-kinesis-kpl
hexo
overriding
io-redirection
cookiecutter-django
http-live-streaming
glew
unixodbc
total-commander
sas-jmp
flickr-api
appcompat
youcompleteme
upstart
logparser
clean-architecture
git-diff
forever
arrow-keys
spring-mongodb
color-profile
eventkit
savon
ptrace
eclipse-clp
icu4j
retina
sframe
android-listview
ios9.1
interrupted-exception
gwidgets
tt-news
java-metro-framework
device-manager
dml
expected-exception
bundles
datagridviewcolumn
prettify
tidy
file-locking
eclipse-memory-analyzer
android-screen-support
orchardcms-1.7
specification-pattern
pvrtc
runas
datawindow
php-parser
gnustep
gcj
sql-server-profiler
mozilla-prism
forums
rescale
brewmp
ubuntu-9.04
signal-handling
ntvdm.exe

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile