User Profile

Collapse

Profile Sidebar

Collapse
jonjon0688
jonjon0688
Last Activity: Oct 12 '10, 07:25 PM
Joined: Mar 24 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Ok, I now realise i need a LinkedList and I think this should be declared in the OrderList class, how do I get the information from the Cashier Thread into the LinkedList?

    Thanks.
    See more | Go to post

    Leave a comment:


  • Multiple threads, require a synchronized list, which can hold multiple variables

    I have the task of creating 3 classes, Cashier, OrderList and cook.

    The cashier adds an order to the OrderList. The order info is the cashiers name, the order number (unique) and the current time.

    I have written code to get the relevant information for the order (see below), however I do not know how to put it in the OrderList, I thought an arrayList could only hold one variable. Also should the list be declared in...
    See more | Go to post

  • jonjon0688
    replied to fileSize help
    in Java
    it says:
    The output should have been:
    countChars

    This is what was actually produced:
    public int fileSize(String name) throws IOException
    {

    try {
    InputStreamRead er isr = new InputStreamRead er(new FileInputStream (name));
    BufferedReader in = new BufferedReader( isr);
    int charLength = 0;
    ...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    no i am still using the reader in the fileSize method, the above method countChars is the one it says to use to create the fileSize method, i was just wondering how i use it?...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    yes it says use this method:

    public int countChars(Inpu tStream input) throws IOException
    {
    int count = 0;
    BufferedInputSt ream input2 = new BufferedInputSt ream(input);
    while(input2.re ad() != -1)
    {
    count++;
    }
    return count;
    }

    but how? what does it mean by 'use' it?
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    like this ..

    public int fileSize(String name) throws IOException
    {

    try {
    InputStreamRead er isr = new InputStreamRead er(new FileInputStream (name));
    int charLength = 0;

    while (isr.read() != -1)

    charLength++;

    return charLength;
    }

    catch...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    ok i understand, so what should i do?...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    sorry i know im being really stupid, but i don't quite understand what you mean?
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    this is what i have:

    public int fileSize(String name) throws Exception
    {

    try {
    InputStreamRead er isr = new InputStreamRead er(new FileInputStream ("name.txt") );

    int charLength = 0;

    while (isr.read() != -1)

    charLength++;

    return charLength;
    ...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    is this what you mean ?

    public int fileSize(String name) throws IOException
    {

    try {
    InputStreamRead er isr = new InputStreamRead er(new FileInputStream (System.getProp erty("user.dir" )));

    int charLength = 0;

    while (isr.read() != -1)

    charLength++;

    return...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to fileSize help
    in Java
    But does the question not state that the file is called "name"? it would not matter whether i have the file or not when i submit my work.
    Is it something to do with where i have placed try {

    thanks for the help
    See more | Go to post

    Leave a comment:


  • jonjon0688
    started a topic fileSize help
    in Java

    fileSize help

    Using the countChars() method from the previous answer, write a method called fileSize() declared as follows:
    public int fileSize (String name) {
    ...
    }

    which counts the number of characters in the file whose name is supplied as the "name" parameter. This method should return the number of characters in the file, or -1 if an IOException occurs.




    public...
    See more | Go to post

  • jonjon0688
    replied to Homework help
    in Java
    same question ..
    public int fileSize(String name) throws IOException
    { try {
    InputStreamRead er isr = new InputStreamRead er(new FileInputStream ("name"));
    int charLength = 0;
    int c;
    while ((c = isr.read()) != -1)


    charLength++;

    return(charLeng th);
    }

    ...
    See more | Go to post

    Leave a comment:


  • jonjon0688
    replied to Homework help
    in Java
    Using the countChars() method from the previous answer, write a method called fileSize() declared as follows:
    public int fileSize (String name) {
    ...
    }
    which counts the number of characters in the file whose name is supplied as the "name" parameter. This method should return the number of characters in the file, or -1 if an IOException occurs.

    This is what i have done :
    public...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...