Hi guys I've written a very simple program that reads in some files, does some cleanup on the data and then creates a sql statement to insert the data into a table. Now I have 125 of these fies of varying sizes and on some (not all) of the files (they are csv files) there are a large number of lines that are essentially empty entries (i.e. a bunch of empty commas). The result of my code is that it seems to hold onto the last correct strings (not the empty ones) and then tries to execute the sql statement. …

Member Avatar
Member Avatar
+0 forum 3

Hello everyone. 1)I am trying several days now to display an image from file Chooser in Netbeans. i have read and tried many different approaches from the web, but something goes wrong.Although the program runs ok,I see no results.Until now, I have used the "Design" tab of Netbeans to create one main Jframe and three Panels. Panel1 for image preview(of course I will implement it much later) Panel2 for buttons like "Add pic","remove" etc.The Add button opens my file Chooser.Now I am trying to load an image from the file Chooser inside Panel3 and of course fit it correctly according …

Member Avatar
Member Avatar
+0 forum 17

Okay, so this is my final assignment for a class I am taking. I'm making a Book Library Database that keeps track of all books that are entered and changed, things like that. I figured a useful feature would be saving your data in a text file so that it could be loaded again any time. I successfully managed to get the program to save my data into a text file but I can't seem to Load that text file in a way that the lines are assigned to their correct variables again. I'll attach some code... (WARNING: It is …

Member Avatar
Member Avatar
+0 forum 11

please some one would explain me why we use Bufferedreader() instead of using InputStreamReader() only.

Member Avatar
Member Avatar
+0 forum 1

Isn't it better to use the BufferedReader function readLine() instead of read() or read(byte[])? The reason I ask is because of potential memory wastage by the read() function. If I specify a byte array of size 10, then it will become capable of accepting ten bytes from the transmitter. However, if the transmitter transmits only four bytes, the remaining six bytes would be wasted. Keeping this in mind, it would be practically smarter to use the readLine() function to avoid any memory wastage. I am an absolute beginner in Java, so please pardon me if I sound incompetent.

Member Avatar
Member Avatar
+0 forum 2

Hi All, I am trying to load from a .dat file a collection of student objects However on load it only loads the first student and then stops I've tried to put print messages in but with all the nulls I really can't seem to work out what is happening. I see the first student added without problems, it's just nothing after that works. If I add a new one before closing the program, I can see it added to the array and when I save, it increases the .dat file size so that seems to be working without a …

Member Avatar
Member Avatar
+0 forum 1

Hello, I currently have this code to buffer an image: [CODE] public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; ImageIcon icon = new ImageIcon("back.gif"); Image image = icon.getImage(); BufferedImage buff = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_ARGB); Graphics2D b = (Graphics2D) buff.createGraphics(); b.drawImage(image,imgX,imgY,this); b.setColor(Color.BLUE); b.fillRect((window.getWidth()/2)-13, (window.getHeight()/2)-13, 26, 26); g2.drawImage(buff, 0, 0, this); } [/CODE] What it (should) do is load a background image. The background moves as I press the arrow keys (changing the imgX and imgY variables). The back.gif image is 5000 pixels square. The issue is that when I don't buffer it flickers, when I use the above code, …

Member Avatar
Member Avatar
+0 forum 2

It's only reading every other line. It's supposed to print out: 28 80.0 22 1 2 2 3 1 3 But it's only reading: 80.0 1 2 1 [CODE]//Load button - #=daynum, $=wallet, @=inventory, &=employees, !=customers if (btn2.getText().equals("Load")){ int id=0; File file = new File("savefile1.txt"); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String text = null; while ((text = reader.readLine()) != null) { text = reader.readLine(); if (text.contains("#")){ text=text.replace("#", ""); dayNum=Integer.parseInt(text); } if (text.contains("$")){ text=text.replace("$", ""); wallet=Double.parseDouble(text); } if (text.contains("!")){ text=text.replace("!", ""); customer.setCustTotalComplete(Integer.parseInt(text)); } if (text.contains("@")){ text=text.replace("@", ""); id=Integer.parseInt(text); BuyInvItem(id); inventory.setNewInv(InvId[id], InvPrice[id], InvName[id], InvSellPrice[id], InvAmt[id], InvBuyPrice[id], …

Member Avatar
Member Avatar
+0 forum 2

Hi all, I'm writing a simple encryption algorithm and have stumbled upon a problem relating to the file handling itself. What my program does is reads text from a file, encrypts it, and writes it to another file. That's all well and good, and it works fine - until a large file is used for input. I tested it with a 30MB file and 300MB file, and got an 'out of memory error - no space on heap' or something like that. I imagine that this is caused due to the way I'm handling the file. To solve it, I …

Member Avatar
Member Avatar
+0 forum 24

The End.