I have assignment to read XML file of University Schedule , there are class rooms, time , weeks, teachers and so on. And I have to read all of them and put them to Data Base. Edit: I have to read everything because that xml is messy and it is hard to recognize everything.
I am asking to you guys, because I am newb in Java and I would like if you guys will direct me in good way how to start everything, because I don't have any idea, from what I have to start.
Thank you.
A convenient way of reading xml-files with java is the JAXB(Java Architecture for XML Binding)
From there you could go with JDBC(Java Database Connectivity)
to save your Objects into a database.
Generally your question is very broad and should be divided into further sub-questions.
Related
I'm currently writing an application which displays items within a ListView which then users can either add to or delete from. I am making this data persistent by writing out to a local JSON file (I'm saving the data as a JSONArray and then calling the toString() method before Serializing it and writing it, reading is basically the same process reversed).
Since I'm fairly new to developing for Android I'm not very clear on the best practices, and specifically I'm interested in what is the best method for accessing data stored within local files and resource files. Currently I'm Reading and writing from these using an AsyncTaskLoader and am wondering if that's sensible for a local file or is not needed/recommended for local files. Is it OK to run on the main thread for accessing local files or is there some other class besides AsyncTaskLoader I can use?
My main problem is that after implementing the AsyncTaskLoader I am seeing some performance issues and being fairly new to development as a whole I suspect I'm not implementing this fairly complex class in an efficient way. If I can avoid it all together or substitute a less complex class to reach a similar result I think I'd be set. Thanks in advance for feedback and if having some code snippets would help clarify the question please let me know.
After searching around for a bit and trying a few different things I found that implementing a SQLLight Database and Cursor Loader was alot faster than trying to Serialize and De-serialize strings to JSON and vice-versa. Also when everything was setup it was a lot easier to implement.
This project is a pretty good example of how to implement this https://github.com/udacity/ud845-Pets .
If your Data file is to big to read and write then you need to use some Thread or AsyncTask. AsyncTask has mainly three methods for batter performance with android UI .
for storing data you can store your json String into SharedPreferences.
see below links for
AsyncTask
And
SharedPreferences
For my Java project I am looking for a convenient way to store my data. I have the following requirements:
It should be easy to synchronize with subversion (which I use for my Java code and other stuff). So I guess file-based is appropriate.
I want to be able to get certain elements without having to read all data into memory. Like in a database ("give me all objects with/without property x", "give me all information about object with certain ID").
I want to be able to read and write in this way.
I guess a database is overkill for my purpose, difficult to sync and I have to be admin/root on all machines to install it. (right?)
So I was thinking of using XML, but I heard that XML parsing in Java does not work very well. Or can anyone point me to a good library?
Then I was thinking of CSV. But all examples I saw (here and elsewhere) read the data into memory before processing it, which is not what I want.
I hope you can help me with this problem, because I am not so experienced with Java.
Edit:
Thank you for downvoting this question without any comment. This is not helpful at all because now I have no new information on my problem and I also have no idea what I did wrong with respect to this community's rules.
You can use Datanucleus (ORM) and use it with an XML Datastore
http://www.datanucleus.org/products/datanucleus/datastores/xml.html
I was wondering how you would go about writing and the reading from an .XML file using the Java library Slick2D.
I have googled for the last couple of days and have found nothing succinct and simple that explains what I'm looking for.
I am looking for 3 things:
How to create an .XML file (would be awesome to be able to search a directory to see if there is an existing file and only create a new file if one does not already exist.
How to write to the created .XML file.
How to read from the found .XML file.
The reason for this is that I'm trying to create a save/load class for a game.
Just a general snippet of code, that I'd be able to modify for my needs would be great even for a learning experience.
So now for my question, does anyone have any information that may help me on my quest to succeed in my above stated three goals?
For checking if a file exists you can use the exists() method of java.io.File. See this for more information.
I don't know if slick2d provides it own xml utilities but you should always be able to use the standard java ways of reading/writing xml. You can use the DocumentBuilder like shown in this tutorial or a sax parser like described here. If you need to work with complex xml structures it might be worth to look into jaxb.
Good Afternoon in my timezone.
In my current web project, i have to write a flat file(with some fixed rules).After a web research i found a library which is called FlatWorm that help's me write flat files in a easy way.The problem is that there is a lack of information regarding the XML definition file.I have the FlatWorm API, but there is nothing related with the XML definition file and all the tags and attributes that build it.
Anyone that use and knows about this framework can give me a clue ?
With best regards.
Thanks in advance
I would start by RTFMing. There appears to be a fair amount of information on there that should get you kick started, including some examples you could start by modifying.
Google suggests some other examples, such as, http://javaconfessions.com/2009/04/writing-flat-files-in-java-with.html and http://andreamoz.blogspot.com/2010/12/meet-flatworm.html
Unfortunately the DTD for the XML descriptor either never existed, or at least doesn't any more. If needed, I would look through the XML parsing source to see what the flatworm library actually makes use of.
heey everyone,
I've got a task from my work where I need to put our customer database on a OSM using .PHP and .JS is this possible? And is it possible to get the info rom our database without having the lat and longtitude of the addresses?
I'm also not very good at programming. thx for everyone that tries to help.
There's a great number of things you need to learn to be able to build the kind of site you're talking about. You need to know several (not just one) programming language, how relational databases work, how HTML and JavaScript work together, and the many different ways geographic information is processed.
To put it another way, it's like saying "I've been asked to build a house, where can I learn the bricklaying I need?". You're being asked too large a task, especially for an intern.
There is a simple example of overlaying markers on an OSM map,simple example of overlaying markers on an OSM map but that needs you to know some JavaScript yourself, which you'll need to learn separately.
got this from someone else on other forum maybe helps other people also still searching for more though if people know some