Creating Inventory File As Random Access File

Oct 26, 2014

I need to write a program that will create an inventory file as a random access file. The problem that I am having is that among the things I need to add to the random access file is a "car name". Since random access files are byte based I don't know how I could possibly write and then read a string value.

View Replies


ADVERTISEMENT

Read Text File Into Object Array And Creating Random Access File

Dec 8, 2014

I am working on a project that requires me to build a database with random access file, representing products, the base product contains a name (about 30 characters), a price (double), and a quantity (integer). I have worked on this project for probably 15+ hours and have tried so many things and feel like I've barley made any progress...

The part i am really struggling with is taking the data from the text file and creating an object array with it using the product class. Once ive accomplished that, i have to use that data to create a random access file with the data.

Here is the base Product class that must be used to create the objects for the array.

public class Product
{
public String pName;
public String stringName;
public double price;
public int quanity;

[Code] .....

And then here is the data from the text file that i must extract to use to create product objects.

Dill Seed,938,34
Mustard Seed,100,64
Coriander Powder,924,18
Turmeric,836,80
Cinnamon (Ground Korintje),951,10
Cinnamon (Ground) Xtra Hi Oil (2x),614,31
Cinnamon (Ground) High Oil (1X),682,19

These continue for about 40-50 entries, they are not separated by a blank line though i had to add those so it would display correctly, each entry is on its own line with name separated with spaces, then price after a comma, then quantity after the second comma.....

View Replies View Related

Reading Text File Into Object Array And Creating Random Access File?

Dec 8, 2014

I am working on a project that requires me to build a database with random access file, representing products, the base product contains a name (about 30 characters), a price (double), and a quantity (integer). I have worked on this project for probably 15+ hours and have tried so many things and feel like I've barley made any progress...

The part i am really struggling with is taking the data from the text file and creating an object array with it using the product class. Once ive accomplished that, i have to use that data to create a random access file with the data.

Here is the base Product class that must be used to create the objects for the array.

public class Product
{
public String pName;
public String stringName;
public double price;
public int quanity;
//Constructor
public Product( String pName, double price, int quanity )

[code]....

and then here is the data from the text file that i must extract to use to create product objects.

Dill Seed,938,34

Mustard Seed,100,64

Coriander Powder,924,18

Turmeric,836,80

Cinnamon (Ground Korintje),951,10

Cinnamon (Ground) Xtra Hi Oil (2x),614,31

Cinnamon (Ground) High Oil (1X),682,19

these continue for about 40-50 entries, they are not separated by a blank line though i had to add those so it would display correctly, each entry is on its own line with name separated with spaces, then price after a comma, then quanity after the second comma.....

View Replies View Related

Reading Text File Into Object Array And Create Random Access File

Dec 9, 2014

I am working on a project that requires me to build a database with random access file, representing products, the base product contains a name (about 30 characters), a price (double), and a quantity (integer). I have worked on this project for probably 15+ hours and have tried so many things and feel like I've barley made any progress...

The part i am really struggling with is taking the data from the text file and creating an object array with it using the product class. Once ive accomplished that, i have to use that data to create a random access file with the data. Here is the base Product class that must be used to create the objects for the array.

public class Product
{
public String pName;
public String stringName;
public double price;
public int quanity;

[Code]...

these continue for about 40-50 entries, they are not seperated by a blank line though i had to add those so it would display correctly, each entry is on its own line with name seperated with spaces, then price after a comma, then quanity after the second comma.....

View Replies View Related

How To Read Data From Random Access File

Jul 10, 2014

I have a random access file stream. I have below code I want to written data that is currently pointed by pointer till the end and display that data on System.out Stream but it is not working my code is

//Create a Random Access File
java.io.RandomAccessFile random=new java.io.RandomAccessFile("D:/input.txt","rw");
//Position the pointer to a seek
try {
random.seek(300);
long pointer=random.getFilePointer();
System.out.println("Current Pointer is:"+pointer);
int a;
while((a=random.read())!=-1) {
System.out.println(a);
}

Where am I wrong? Although it is returning actual position of pointer in pointer using

View Replies View Related

Random Access File - How To Retrieve Particular Set Of Data

May 4, 2015

I am creating a read/write, RandomAccessFile that I will use to store several student ID and gpa score. What I don't understand is how I should go about retrieving a particular set of data.

public class ReadWrite {
static Scanner keyboard = new Scanner(System.in);
static String fileName = "Stu.dat";
static RandomAccessFile raf;
public static void main(String [] args) throws FileNotFoundException, IOException {

[Code] .....

View Replies View Related

Saving Picture From Byte Arrays Using Random Access File

Jul 12, 2014

I'm trying to save a picture from byte arrays using RandomAccessFile. The file appears but doesn't open (like its corrupted).

I'm using the bittorent protocol which gives a SHA-1 hash that I compare all the bytes with to verify the data. All the bytes pass the hash check and all the hashes are checked. So I'm pretty sure I'm getting all the bytes correctly.

Is there anything I can do that could tell what's going wrong?

public RUBTClient(final TorrentInfo2 tInfo, final String outFileName) {
...
this.outFileName = outFileName;
File destined = new File(outFileName);
try {
destined_file = new RandomAccessFile(destined, "rw");
destined_file.setLength(tInfo.file_length);
} catch (FileNotFoundException e1) {

[Code] .....

View Replies View Related

Write Data For Three Products To Random Access File - Unexpected EOFException

Jul 11, 2014

I'm trying to write data for three products to a random access file, but I have a problem. Each product has a code and a price. After writing them to my file, I want to get to the second field or product. I do this by getting the length for each record, and multiplying it by the field number I want to go to. I use the result for the seek() method of the RandomAccessFile object. It is giving me an EOFException, but when I use 0 for the seek method i get the data for the first poduct or field.

Java Code:

public static void main(String[] args) {
final int RECORD_LENGTH = 16;
try(RandomAccessFile productsOutput = new RandomAccessFile("C:UsersalfonsoDesktopBinaryTestRandom.ran", "rw")) {
String[] codes = {"java", "jsps", "txtp"};
double[] prices = {49.5, 19.9, 29.9};
for(int i = 0; i < codes.length; i++) {

[Code] .....

View Replies View Related

Creating A System That Will Ask User To Create A File That Will Store To Text File

Mar 9, 2015

I am new to java and I am creating a system that will ask the user to create a file that will store to a text file, Once the user created the file I have a class that will let the user input the subject name that has been created, However, I keep on getting this java.util.nosuchelementexception.Here's my code:

public void display_by_name()
{
String id, name,total;
String key[]=new String[30];
String value[]=new String[30];
int i=0;

[code]....

View Replies View Related

Adding Sort And Total Inventory Methods In Inventory Class

Apr 30, 2014

for my assignment I am to only add the sort and total inventory methods in the inventory class. And not create an array in the inventory class at all. My inventory class should contain all the variables needed to use with the two new methods: sort and calculate total inventory.By not creating any array in the inventory class and not touching the variables at all.

What I have came up with is:

public class inventory
{
private int prodNumber; // product number
private String prodName; // product name
private int unitsTotal; // total units in stock
private double unitPrice; // price per unit
private double totalInventory; // amount of total inventory
// initialize four-argument constructor

[Code] ....

The error message I get is:

F:Java Programminginventory.java:62: error: cannot find symbol
return prodName.compareTo ( s. getprodName() );
^
symbol: method getprodName()
location: variable s of type inventory
1 error

View Replies View Related

How To Access A File Within Executable Jar

Nov 21, 2014

So let's say i have an executable jar and inside that jar is a bunch of files. How do I access files within my jar?

Assuming like, a main class is currently running and that is what's inside the manifest file as the main class inside that executable jar..

View Replies View Related

Random File Name Generator

Nov 30, 2014

I am splitting a zip file and want to name each fragment with a random name. I want to use java coding for generating this random file name.

View Replies View Related

How To Open Random Input File

Oct 30, 2014

i dont know how to write main that would open the input file and read using this method...

[/package AssignmentSeven;
import java.io.*;
import java.util.Scanner;
public class Assignment7
{
public static void Towers(int nTowers, int fromTower1, int workTower2, int toTower3) {
if(nTowers == 1)

[code].....

View Replies View Related

Access Is Denied While Compiling The Java File

Oct 30, 2014

I am getting an error as follows while trying to compile a java file for servlet:-

"error while writing BeerSelect: WEB-INFclassesBeerSelect.class (Access is denied)
public class BeerSelect extends HttpServlet
^
1 error"

I am using "C:Program FilesApache Software FoundationTomcat 8.0webappsBeerBottlejavac -d WEB-INFclasses BeerSelect.java" to compile the file.

I am using Windows 8.1

View Replies View Related

Designing Jar File Where Access Of Certain Database Provided Through API

Jan 30, 2015

I'm given a task to generate an API (a jar file) where the access of a certain database is provided through the API. basic functionality: Client sends a query through the API to server and the Server responds with data.Since its and API, do I have to implement the code or is it enough if i gave just interfaces? what are the OOP concepts to focus on when designing a good API.

View Replies View Related

Access Denied To Create Class File

Aug 10, 2014

I am new to java. While compiling the "moooooo" program an error is displayed.

Error -- error while writing MooseGreetings :MooseGreetings.class
<access denied>.

What to do?

View Replies View Related

Can Access One Class Present In One Source File

Nov 3, 2014

I am having hard time to grasp the concept of java as i am beginner. according to different sources found in internet, only one class is written in one source file. and all those class can be accessed through the main class.
my question is

1.can we access one class present in one source file, through another class present in another source file [not through the class containing main method]?

2.can we create more than 1 class in same source file?is there special way to do it? i do get error always when i try to do so
3.can multiple classes contain main method? or should there be only single class containing it?

View Replies View Related

JSP :: How To Access Variable Of Java File Into Page

Jul 4, 2014

I want to access variable of java file into jsp Page. So I tried to do this but it does not work.

Problem : when I am trying to access "getName" method of java class into jsp file it displaying error, i already imported "Ajaxmethod.java" file in to "success.jsp" I want to access "getName" method in to jsp file without creating object of class.

Ajaxmethod.java
package a.b;
public class Ajaxmethod implements Action{
public String name;
public String getName() {
return name;
}

[Code]...

View Replies View Related

Cannot Access Class File From Package Inside JAR

Mar 7, 2015

I'm trying to access class file which is inside the package and package is inside the jar file but I can't access that class file inside my source file . All files are on desktop .

View Replies View Related

How To Access Oracle DB Without Using ODBC Driver Jar File

Oct 15, 2014

I need to access Oracle database without using ODBC driver using DAO only, how to do that...

View Replies View Related

Java Source Code File Naming With Access Modifiers

Feb 3, 2014

Why is this not valid in java:

Both uses public with the same class/interface name.

Test.java:
public class Test implements Test{
/// Some codes
}
public interface Test {
///Some methods
}

View Replies View Related

Creating A Package File

Aug 14, 2014

Though have been playing around with my ebook but finding it difficult to get along with the topic PACKAGE&INTERFACES, I find it challenging to write a package file despite the book I currently studying and online tutorial.. so I want a more explanatory format to comprehend the piece cos without knowing it.

View Replies View Related

OpenCSV When Creating JAR File

Mar 1, 2014

I'm having a problem with using the openCSV library when I create a JAR file. I'm currently using BlueJ to run my code. When I compile my program in there, I have no problems whatsoever and it runs great, yet when I create my program into a JAR file, my application doesn't work.

I would think that my problem is either stemming from faulty exception handling, although I don't understand why an input would work in the BlueJ environment, but not when using the JAR file. Or, perhaps the openCSV library isn't in a correct class path(I don't know if this is correct terminology).

View Replies View Related

Possible To Delay Creating A File

Sep 26, 2014

It is possible to delay the creation of a file until I know I am writing to it.

View Replies View Related

Creating File Directory

May 12, 2014

I am working on a java logic game and I want it to be able to work on other people's Mac's, so I tried to figure out how to make it create a folder in which it can create files. The file creating is going fine however the folder never seems to create.Here is the code I attempted to use:

File logicFile = new File("/Library/Application Support/LogicGameSupport");
if(!logicFile.exists()){
if(logicFile.mkdir()){
System.out.println("Directory success");
}else{
System.out.println("Directory failed");

}

}

View Replies View Related

Creating XML File In Java

Jul 30, 2014

I'm getting a DOMException, "HIERARCHY_REQUEST_ERR". I know that the problem is from the following code towards the bottom in my function, but I don't know how to deal with it. When I get rid of doc.appendChild(staff);, I get rid of the problem, but it obviously doesn't add the new entry to my root element.

Element staff = doc.createElement("Staff");
doc.appendChild(staff);

import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved