Indenting a tree file structure from string input - java

Click here to see a screenshot of the assignment
Here is how the Navigation.csv looks like, where I take data from
https://pastebin.com/JXnaRTzi <-- Click on the link for code - this is my code so far, I am reading the file and making objects from each entry
Guys I need help with this assignment. I chose to do it in Java, but really it doesn't matter. I need advise and help for making the right approach on this kind of problem so it can work on a larger file. What kind of data structures should I use and maybe if it's no bother, give me a solution. I am a new developer and I'm trying to get into backend and frankly I'm a bit lost.
Click on links above to see the task details.

Related

atom-java-snippets: Render the snippets.cson file in real-time before typing prefix in java file?

Hello world! My name is Hank Igoe and this is my first time posting. I've been using atom-java-snippets with the Atom IDE, and they work great. There is one minor tweak I'd love to have, though. It would be nice to have a WYSIWYG pane for the 'body' section that showed what it would look like after rendering from the snippets.cson file.
For example, here's a snippet to make a Java interface:
'snippet-interface':
'prefix': 'iface'
'body': 'public interface ${1:IfaceName} {\n
${2:METHODS}\n}${3}'
It's not that hard to read, but it would be great if there were a third pane that showed the rendered version of the body, like this:
public interface IfaceName {
METHODS
}
Then I would know it's ready for the code file, and could quit tweaking it to get the spacing right, etc. Of course, you can do this manually by going to the java file, typing the prefix, see what the .cson snippet prints out, then tweak the .cson file if the formatting is off, and lather rinse repeat until it's just right. But I was thinking it would be nice to have the instant feedback that you get when, say, doing html/markup editing in an editor that can do realtime updates.
Anyway, I hope that question is clear, please feel free to post a question if you need clarification.
btw, if such a thing doesn't exist but you all think it's a good feature and would like to add it to atom-java-snippets or create a new plugin, I'd be happy to help out if I can.
Thanks in advance for any advice,
Hank
http://linkedin.com/in/hank-igoe-27419519b/
http://github.com/vujadetech
http://facebook/hank.igoe54

Best file type to save budget data in Java?

I'm starting on a new budgeting/allowance project and I'm trying to figure out how to save the data between opening and closing the program. Arrays seem clunky and I don't know how I would save the array data to a file anyway. I've really only worked with text files before so this is new to me.
I'm assuming a database of some sort is what I need but I don't know what I should be looking for.
I know this has to be a simple issue but I honestly don't know where to start; any help is greatly appreciated.
That is entirely for you to decide, there is no one right answer here.
You can save in a text file, e.g. CSV if very simple, otherwise JSON or XML are common choices, or in a binary file, e.g. Java serialized objects, or some embedded database file might do.
It really depends on how complex the data is, how big the file can become, whether you want to be able to edit the file directly in a text editor, and how important load/save performance is to you.
Since it's a new project and you seem fairly new to this, I'd suggest JSON or XML, whichever of the two you are more familiar with. But that's just my opinion.
It's entirely your choice.

grabbing information off answer sites

First off let me say language of preference is Java but any language is acceptable for the answer since I know most languages.
Question: Say I have a link, http://ca.answers.yahoo.com/question/index?qid=20140218053709AAM0WfI (random link for this example). Is there any possible way to get the title of the question and store it in a string, then get what he typed as the description for the question(aka this section here) and store it in a separate string? I know how to grab strings from a site but the problem I run into is that I keep grabbing answers aswell as the question.
Additional details.
I will not know the specific yahoo answer ahead of time, so the code
needs to be able to work with all basic questions (aka ones without
picture or other complications).
Code needs to work with all question/answer forum kinda sites not just yahoo.
Not asking anyone to write entire code or anything, I know that is not how site works. Just is there any specific functions that can easily obtain this information?
What you want is data scraping. You can use Beautiful Soup for that purpose. below is the link of one of the tutorials.
http://kochi-coders.com/2011/05/30/lets-scrape-the-page-using-python-beautifulsoup/

Create a pdf with text at given coordinates (PDFBox?)

My Situation:
I'm programming in java
Using a library from a person from my university I'm able to read pdfs and create a XML document out of it
This XML document contains additional informations e.g. the coordinates of the text in the original document
My Problem
I would like to create the read PDF again with the content set at its original coordinates (Again: I have the coordinates)
My Question:
-> Do you know a way to create a pdf and set the text of the pdf at given coordinates? <-
I'm doing a lot of research these days about, but maybe I tried the wrong google search terms since I cant find much helpful results. So i thought I might be able to ask here, in the forum where I found the most help so far in my young "programmers life" :)
Most of the results I get, even here, are about people trying to get the coordinates, but I already have them.
I heard during a discussion that PDFBox might be able to do this, but I'm also happy to work with any other framework or library that is capable for my problem.
Thanks for every help and thought you're sharing with me.
Thanks a lot for your comments. In the end I've decided for iText, which allowed me to do all my tasks (placing text at absolute coordinates, give it a background color by certain criterias) in a quite easy and efficient way.
If someone here is searching for inspiration and has a similar task, check my related post here on stackoverflow for some code snippets How can I add a background color to my (pdf-) text using iText to create it with Java

Please help, my program is not accepting MySQL floats

I have to use a java program . I need to understand it and then modify it. The program has a source folder. It has a lot of java files. the program has a GUI interface. i have imported the program in eclipse and i can run the program. i want to learn and understand the code but since its too big i want to only read the relevant portions of the code which i need to understand to modify / add features to the program. This program requires input data . this data can be in a CSV file or a MySql database. the immediate problem i am facing with the program is that i need to use float data as input data in one of the columns. when i put data in decimal form in the CSV file . the program has no problem in accepting it and processing it. but when i create a MYSQL database table with floating datatype as one of the column . the program while importing data gives error - "unknown data type float . add this entry is xxx.props file " even after i add the float entry in xxx.props file in the proper way just as other entries are there for other data types in xxx.props file, i still get the same error . what should i do next ? which part of the code should i study to find out the problem?
When you say it "gives error" - does it throw an exception? If so, find out where that exception is thrown from, and work backwards from there.
You haven't explained what the xxx.props file is, how you created the mysql table, or what you're then doing with it, which makes it kinda hard to give any more specific help...
Without a direct question, I can't help you much. However, I can advise you on how to solve the problem.
Learn the basics before you try to make a leap to do everything at once. Try to learn these before coming everything:
Get a working knowledge of Java
Figure out how to develop a GUI that isn't binded to your logic. (Take a look at the MVC design pattern)
Break up the big program into manageable parts
Implement your logic separately from your data access (M C part of MVC)
Use Unit Testing to verify that your components work
Implement the CSV reading, and then move it to the database
This way you have seperable components that will make your job easier to deal with, and you will learn quite a bit along the way.
You've got a lot of small questions but I think your main question is "why am I getting this 'unknown data type float' error". Without looking at any code my first suggestion would be to validate how you're inserting/updating the MySQL table. Hopefully the developer extrapolated the data tier from the UI tier meaning there should only be one or two java classes to look at to verify how the data is inserted.
Overall, it sounds like you're new to Java and application design. Try to follow how the program works from point A to point B. Hopefully the code was broken out into tiers to make it easier for you; IE the GUI is in it's own package/project and the business logic is in it's own package/project, so on and so on.

Categories

Resources