hi
i have this code
but i have problem that is
i can ensert the NO of job and saved it on txt file named by memory
but when i close the file memory all data on this file is lost , how can i saved it without lost data
and i wont to make the file memory on the 100 kb
and when enter the total of the job great than 100 kb the program must be send for me message " i canot saved more than 100 kb "
help me
this code i upload it on this sit http://www.2shared.com/file/2387324/...a/Fitting.html 21 1814
hi
i have this code
but i have problem that is
i can ensert the NO of job and saved it on txt file named by memory
but when i close the file memory all data on this file is lost , how can i saved it without lost data
and i wont to make the file memory on the 100 kb
and when enter the total of the job great than 100 kb the program must be send for me message " i canot saved more than 100 kb "
help me
this code i upload it on this sit
http://www.2shared.com/file/2387324/a059371a/Fitting.html
You want us to help you and yet you post your code elsewhere?
Come on don't be lazy. It's just a matter of copy and paste. And use code tags when you post the code.
hi
i have this code
but i have problem that is
i can ensert the NO of job and saved it on txt file named by memory
but when i close the file memory all data on this file is lost , how can i saved it without lost data
and i wont to make the file memory on the 100 kb
and when enter the total of the job great than 100 kb the program must be send for me message " i canot saved more than 100 kb "
help me -
-
import java.awt.*;
-
import javax.swing.*;
-
import java.io.*;
-
import java.io.FileNotFoundException;
-
import java.lang.SecurityException;
-
import java.util.*;
-
import java.util.Formatter;
-
import java.util.FormatterClosedException;
-
import java.util.NoSuchElementException;
-
import java.util.Scanner;
-
-
import java.io.InputStream;
-
import java.io.OutputStream;
-
import java.io.FileInputStream;
-
import java.io.FileOutputStream;
-
import java.io.FileReader;
-
import java.io.FileNotFoundException;
-
-
public class FittingAllgorithm
-
{
-
private Formatter output; // object used to output text to file
-
-
// enable user to open file
-
public void openFile()
-
{
-
try
-
{
-
output = new Formatter( "memory.txt" );
-
} // end try
-
catch ( SecurityException securityException )
-
{
-
System.err.println(
-
"You do not have write access to this file." );
-
System.exit( 1 );
-
} // end catch
-
catch ( FileNotFoundException filesNotFoundException )
-
{
-
System.err.println( "Error creating file." );
-
System.exit( 1 );
-
} // end catch
-
} // end method openFile
-
-
// add records to file
-
public void addRecords()
-
{
-
// object to be written to file
-
Job record = new Job();
-
-
Scanner input = new Scanner( System.in );
-
-
System.out.printf(
-
"%s\n%s\n%s\n%s\n%s\n","********************\n\nFitting Algorithem\n\n********************\n\nThis Create By\n",
-
"Khalid Ahmed Almallahy\n20032348\n\n********************\n",
-
"Supervesor by",
-
"\nMoamar Elyazgi.\n\n********************\n\n",
-
"Hint :- \n When You Wont to Exit Press <CTRL>+z\n\n========================================================\n\n" );
-
-
System.out.printf( "%s\n%s\n",
-
"Enter First Jop 'Process' number must be greater than 0\n Second Job 'Process'\n Third Job 'Process'\n last Job 'Process'",
-
"?" );
-
-
while ( input.hasNext() ) // loop until end-of-file indicator
-
{
-
try // output values to file
-
{
-
// retrieve data to be output
-
record.setAccount ( input.nextInt() );
-
record.setaccount1( input.nextInt() );
-
record.setaccount2( input.nextInt() );
-
record.setaccount3( input.nextInt() );
-
-
if ( record.getAccount() > 0 )
-
{
-
// write new record
-
output.format( "%d %d %d %d \n",
-
record.getAccount(),
-
record.getaccount1(),
-
record.getaccount2(),
-
record.getaccount3() );
-
} // end if
-
else
-
{
-
System.out.println(
-
"Job number must be greater than 0." );
-
} // end else
-
} // end try
-
catch ( FormatterClosedException formatterClosedException )
-
{
-
System.err.println( "Error writing to file." );
-
return;
-
} // end catch
-
catch ( NoSuchElementException elementException )
-
{
-
System.err.println( "Invalid input. Please try again." );
-
input.nextLine(); // discard input so user can try again
-
} // end catch
-
-
System.out.printf( "%s %s\n%s", "Enter account number greater than 0,",
-
"first Job, Second Job and Third Job and so on.", "?\n" );
-
} // end while
-
} // end method addRecords
-
// close file
-
public void closeFile()
-
{
-
if ( output != null )
-
output.close();
-
} // end method closeFile
-
-
-
//////////////////////////////////////////////////////////////////////////
-
-
-
int memory,dummycount;
-
int process;
-
int[] bestfit,worstfit,nextfit,firstfit;
-
-
public void place()
-
{
-
Job record = new Job();
-
-
Scanner inFile1= new Scanner(System.in);
-
Scanner iFile= new Scanner(System.in);
-
-
-
-
dummycount=0;
-
while (inFile1.hasNext())
-
{
-
memory = inFile1.nextInt();
-
dummycount=dummycount+1;
-
}
-
firstfit =new int [dummycount];
-
-
inFile1.close();
-
-
-
System.out.println("------For FirstFit algorithm---------");
-
-
inFile1= new Scanner(System.in);
-
-
dummycount=0;
-
while (iFile.hasNext())
-
{inFile1= new Scanner(System.in);
-
-
process = iFile.nextInt();
-
while (inFile1.hasNext())
-
{
-
-
memory = inFile1.nextInt();
-
if ((memory >=process)&&(dummycount< firstfit.length)&&(firstfit[dummycount]==0))
-
{
-
firstfit[dummycount]=process;
-
-
-
System.out.println("memory partition" +" "+ memory +" will accomodate process that need"+ " " +process);
-
}
-
}
-
-
-
dummycount++;
-
inFile1.close();
-
}
-
-
iFile.close();
-
-
-
-
System.out.println("------For BestFit algorithm---------");
-
-
-
nextfit =new int [dummycount];
-
-
-
-
-
System.out.println("------For NextFit algorithm---------");
-
dummycount=0;
-
System.out.println("Got this far");
-
iFile= new Scanner(System.in);
-
-
while (iFile.hasNext())
-
{
-
-
process = iFile.nextInt();
-
inFile1= new Scanner(System.in);
-
while (inFile1.hasNext())
-
{
-
-
memory = inFile1.nextInt();
-
if ((memory >=process)&&(dummycount< nextfit.length)&&(nextfit[dummycount]==0))
-
{
-
nextfit[dummycount]=process;
-
-
System.out.println("memory partition" +" "+ memory +" will accomodate process that need"+ " " +process);
-
}
-
}
-
-
-
dummycount++;
-
-
}
-
-
System.out.println("dummycount" +" "+dummycount);
-
inFile1.close();
-
iFile.close();
-
-
System.out.println("------For WorstFit algorithm---------");
-
-
return;
-
-
}
-
-
public static void main( String args[] ) throws FileNotFoundException
-
{
-
FittingAllgorithm application = new FittingAllgorithm();
-
-
application.openFile();
-
application.addRecords();
-
application.place();
-
application.closeFile();
-
} // end main
-
} // end class CreateTextFile
-
-
-
-
-
public class Job
-
{
-
private int account;
-
private int account1;
-
private int account2;
-
private int account3;
-
-
public Job()
-
{
-
// constructor
-
}
-
-
-
public Job( int acct, int account11, int account22, int account33 )
-
{
-
setAccount( acct );
-
setaccount1( account11 );
-
setaccount2( account22 );
-
setaccount3( account33 );
-
}
-
-
-
public void setAccount( int acct )
-
{
-
account = acct;
-
}
-
-
-
public int getAccount()
-
{
-
return account;
-
}
-
-
-
public void setaccount1( int account11 )
-
{
-
account1 = account11;
-
}
-
-
-
public int getaccount1()
-
{
-
return account1;
-
}
-
-
public void setaccount2( int account22 )
-
{
-
account2 = account22;
-
}
-
-
-
public int getaccount2()
-
{
-
return account2;
-
}
-
-
-
public void setaccount3( int account33 )
-
{
-
account3 = account33;
-
}
-
-
-
public int getaccount3()
-
{
-
return account3;
-
}
-
}
-
-
-
-
-
Read this article.
What do you mean by the total of the job greater than 100kb? Do you mean that the file size should not exceed 100kb?
Read this article.
What do you mean by the total of the job greater than 100kb? Do you mean that the file size should not exceed 100kb?
yes i wont to size of my file 100 kb
how can i do
or can u write code of this
ok
i see the article
but my code is true
but there are code that it saved any data on file
how write this code
yes i wont to size of my file 100 kb
how can i do
or can u write code of this
Use the File class. Open the API specs for it. It has a method for determining the size of a file. Just check your file's current size before adding data to it.
ok
but i dont have it is
can u write code
ok
but i dont have it is
...
What do you not have?
ok
..
can u write code
Some people think I can and some people think I can't ...
You'll have to write this yourself. We are here only to help you when you get stuck.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sugapablo |
last post by:
I have two ASP pages. They basically query a database, and spit out the
information as plain text in CSV format.
The first has the SQL query hardcoded into it. The second takes a SQL
query from a webform.
Now, the hardcoded results, I can click "Save Page As" when the results
come up and save it as a text file.
The other, while it seems to be the same results exactly, gives me an
|
by: Jörg Braun |
last post by:
Hello NG,
i have a problem With WebRequest!
i want to download a htaccess saved file over a proxyconnetion with
authentication.
Download a file what is not saved with htaccess is no problem, download a
htaccess saved file with out a
proxy with authentication i also no problem, but download this file with
htaccess and the auth proxy is a prob!
|
by: harvie wang |
last post by:
In .Net,Through System.Configuration.ConfigurationSettings Get Application's
Settings
I can't find the Configuration Value from Register
Where the ConfigurationSettings saved?
How to Read it except System.Configuration?
Thanks!
Harvie
|
by: mchamsters |
last post by:
Just want to rant about something horrible that happened to me tonight.
It was my first time using the new Visual C#. I started a new project,
coding away continuously for about 6 hours. I saved and executed my
code multiple times. I'd assume the source files are saved safely
somewhere, but I was wrong... My computer crashed and I had to reboot
it, without saving the project (the .sln file). When I started my
computer, the project and the...
|
by: charliewest |
last post by:
Hello -
I have images saved in my SQL SERVER 2000 database. Using ASP.NET (C#) is
there any way to temporarily save an image to a session object, and after
running some other operations, later retrieve the image from the session
object, convert it back to an image, and re-save it to the database?
Thanks?
| |
by: Rich Wallace |
last post by:
Hello all,
Looking for suggestions and tips if possible.
I have an application running on a file server that utilizes the
FileSystemWatcher to trap when any Excel files are saved by a user. I then
need to 'trap' the current file and generate an XML file from the data
within the active spreadsheet. I have two issues so far with doing this...
Issue 1: Once a file that is being watched is saved, I grab it using the
|
by: Peter Proost |
last post by:
Hi group, I've got a question about the size of a saved bitmap.
What I need to do is open a bitmap if it needs resizing, resize and save it.
This isn't a problem, but the problem I have is that the original image has
got an 8 bit indexed pixelformat,
but you can't create a graphics object for this pixelformat so my bitmap
uses the default pixelformat:
Format32bppArgb, but this ofcourse result in a much larger file size (420kB
instead of...
|
by: Sharon |
last post by:
I have an XML question:
I'm have an XML node of type PointF and when it's saved to a file by
XmlDocument.Save(...) it saves as I expect it to be saved:
<ImageOrigin>{X=1.2, Y=3.4}</ImageOrigin>
But on my boss laptop this XML node is saved as:
|
by: nanaalwi |
last post by:
Greetings,
Currently im doing an invoice software in which it will automatically save all the data entered by the user into excel file. Then when the user click 'SAVE' button, the excel file will be saved. However, the size of the saved file is very big which is 1.46MB, but if the data is inserted manually into excel (without using the software), the size is only approximately 60kB. Does anyone know what's the problem? Please Help...
Your...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |