writefile

Read data from a text file and create an object

為{幸葍}努か 提交于 2019-11-30 07:45:11
I need some help: I'm making a Supermarket simulation on Java, but I've got one problem, I have a text file (Stock.txt) where I have all the supermarket stock on it for example: 0-Bakery-Chocolate Cake-$12.5-250 1-Meat-Premium Steak-$2.6-120 2-Seafood-Tuna - $1.2-14 ... Where the first number is the "id" for the product, next is the department the product belongs, third is the name of the product, the next thing is the price, and the last number is how much pieces of the product the stock has. I have this class: public class Product { protected String name; protected double price; protected

writing JSON object to .json file on server

≯℡__Kan透↙ 提交于 2019-11-27 14:31:13
I'm trying to write my JSON object to a .json file on the server. The way I'm doing this now is: JavaScript: function createJsonFile() { var jsonObject = { "metros" : [], "routes" : [] }; // write cities to JSON Object for ( var index = 0; index < graph.getVerticies().length; index++) { jsonObject.metros[index] = JSON.stringify(graph.getVertex(index).getData()); } // write routes to JSON Object for ( var index = 0; index < graph.getEdges().length; index++) { jsonObject.routes[index] = JSON.stringify(graph.getEdge(index)); } // some jQuery to write to file $.ajax({ type : "POST", url : "json

Writing JSON object to .json file on server

六月ゝ 毕业季﹏ 提交于 2019-11-26 16:39:31
问题 I'm trying to write my JSON object to a .json file on the server. The way I'm doing this now is: JavaScript: function createJsonFile() { var jsonObject = { "metros" : [], "routes" : [] }; // write cities to JSON Object for ( var index = 0; index < graph.getVerticies().length; index++) { jsonObject.metros[index] = JSON.stringify(graph.getVertex(index).getData()); } // write routes to JSON Object for ( var index = 0; index < graph.getEdges().length; index++) { jsonObject.routes[index] = JSON