Need help w/ file uploading!
hi! i'm writing a JSP where the client has the possibility to upload image-files
to the server.. anyone have a good way to it? and if so how?
if you are referring me to some java-classes i would like to get proper
information on how to append them in the best way possible...
i've heard about the MaybeUpload package by Weft but there's one thing i
don't understand... in the form you use the <input file=""> tag, but how do i
obtain the file? if use request.getParameter() i would get the path, wouldn't i??
hope you can help me out!
read this.
http://www.onjava.com/pub/a/onjava/2001/04/05/upload.html?page=1
Similar Messages
-
Need help for file upload - reposted for Steve Muench
Hi Steve,
I have been involved developing a web application that requires a file upload operation. I have studied your example on Upload Text File and Image Example in the Not Yet Documented ADF Sample Applications section. I got the file upload part worked but could not get the original file name to populate the name field..i.e. if I upload myFile.txt to the database, the name field will be myFile.txt (not the name enter by user). Is there a way to capture the filename info? or is it possible to do so within ADF framework? I am using ADF/Struts/JSP with ORDDoc data type. Thanks very much.
BillHello Nani,
You need to change any settings in 'FILE' transaction. This transaction is used to set up Logical file paths. ( In general it will be set already for your system).
You can use the following code.
DATA: LC_LOGICAL_FILENAME_EXPSRC LIKE RCGIEDIAL-IEFILE
VALUE 'EHS_IMP_SOURCES'.
DATA: L_EMERGENCY_FLAG TYPE C.
DATA: L_FILE_FORMAT LIKE FILENAME-FILEFORMAT.
data : X_RCGIEDIAL LIKE RCGIEDIAL occurs 0 with HEADER LINE.
read the default pathname on application server
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = LC_LOGICAL_FILENAME_EXPSRC
OPERATING_SYSTEM = SY-OPSYS
parameter_1 = ' '
PARAMETER_2 = ' '
USE_PRESENTATION_SERVER = ' '
WITH_FILE_EXTENSION = ' '
USE_BUFFER = ' '
IMPORTING
EMERGENCY_FLAG = L_EMERGENCY_FLAG
FILE_FORMAT = L_FILE_FORMAT
FILE_NAME = X_RCGIEDIAL-IEFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
write :/ 'file format', L_FILE_FORMAT,
/ 'file name', X_RCGIEDIAL-IEFILE.
Thanks,
Jyothi -
Need help on File uploading in JSF
Hi All,
i have to upload some document into IBM DB2 Content Management using JSF Portlet.
Is it possible to upload a document( in my case it is an image) using JSF Portlet into IBM DB2 Content Management? and also i need to keep the reference of the uploaded document in DB2 database.
i need some sample code to do this.
the tools i am using are
RAD 6.0 as IDE
IBM DB2 Content Managener 8.3
IBM DB2 8.2
its an urgent requirement please help me out in this regardIf it's possible in Portlets i don't know, but in JSF is possible with the Tomahawk component to upload files.
See
www.myfaces.org
Try it. -
I am setting up a new iMac and need help syncing files to Dropbox. On my old computer I had it set where when I saved a document, it was saved on my hard drive, as well as to a folder in Dropbox. I can't remember how I set this up. Any help?
The way that Dropbox works is that it keeps a copy of all your files in your local Dropbox folder on your hard drive (which is, by default, directly under your home folder). Adding files to that folder will sync them to the Dropbox server.
You do of course have to download the Dropbox application to enable this (download link at the top right of http://dropbox.com ).
Matt -
HELP! File Upload Servlet and Internet Explorer
Hello people. I hope this is an easy problem to solve...
I have a servlet upload program that works using Mozilla browser (www.mozilla.org), but for some reason it doesn't work using Microsoft IE. The servlet is also using the servlet upload API from Apache (commons).
I'm using IE version 6.0.2800.1106 in a Win98SE host computer. I get a cannot find path specified error message (see below). At work, I also get the same error message using IE, but don't know what version. The OS is XP. Unfortunately, at work, I can't install Mozilla browser (or any software-company policy) to see if Mozilla works there too. I would've like to have tested to see if the upload program worked on Mozilla on a truly remote computer.
So I figured, it must be a IE configuration issue, but darn it!! I began by resetting IE to default settings, but still have the problem, I played around with several different combinations of settings in "Tools"-->"Internet Options...", and I still get the error message. Someone PLEASE HELP ME!!!
Dunno, if it will help, I've also pasted the upload servlet source code below and the html file that's calling the upload servlet, but you still need the Apache commons file upload API.
Trust me on this one folks, for some reason it works for Mozilla, but not for IE. With IE, I can at least access web server, and therefore, the html file that calls the upload servlet , so I don't think it's a Tomcat configuration issue (version 5.0). I actually got the code for the file upload servlet from a book relatively new in the market (printed in 2003), and it didn't mention any limitations as far as what browser to use or any browser configuration requirements. I have e-mailed the authors, but they probably get a ton of e-mails...
Anyone suggestions?
Meanwhile, I will try to install other free browsers and see if the file upload program works for them too.
ERROR MESSAGE:
"HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: C:\TOMCAT\webapps\MyWebApps\files\C:\WINDOWS\Desktop\myfile.zip (The system cannot find the path specified)
com.jspbook.FileUploadCommons.doPost(FileUploadCommons.java:43)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.io.FileNotFoundException: C:\TOMCAT\webapps\MyWebApp\files\C:\WINDOWS\Desktop\myfile.zip (The system cannot find the path specified)
java.io.FileOutputStream.open(Native Method)
java.io.FileOutputStream.(FileOutputStream.java:176)
java.io.FileOutputStream.(FileOutputStream.java:131)
org.apache.commons.fileupload.DefaultFileItem.write(DefaultFileItem.java:392)
com.jspbook.FileUploadCommons.doPost(FileUploadCommons.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
Apache Tomcat 5.0.16"
FILE UPLOAD SERVLET source code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.commons.fileupload.*;
import java.util.*;
public class FileUploadCommons extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.print("File upload success. <a href=\"/MyWebApp/files/");
out.print("\">Click here to browse through all uploaded ");
out.println("files.</a><br>");
ServletContext sc = getServletContext();
String path = sc.getRealPath("/files");
org.apache.commons.fileupload.DiskFileUpload fu = new
org.apache.commons.fileupload.DiskFileUpload();
fu.setSizeMax(-1);
fu.setRepositoryPath(path);
try {
List l = fu.parseRequest(request);
Iterator i = l.iterator();
while (i.hasNext()) {
FileItem fi = (FileItem)i.next();
fi.write(new File(path, fi.getName()));
catch (Exception e) {
throw new ServletException(e);
out.println("</html>");
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);
HTML PAGE that calls the upload servlet:
<html>
<head>
<title>Example HTML Form</title>
</head>
<body>
<p>Select a file to upload or browse
currently uploaded files.</p>
<form action="http://##.##.##.####/MyWebApp/FileUploadCommons"
method="post" enctype="multipart/form-data">
File: <input type="file" name="file"><br>
<input value="Upload File" type="submit">
</form>
</body>
</html>
Thanks in advance for any assistance.
-DanI'm guessing what is happening is that Mozilla tells the servlet "here comes the file myfile.zip". The servlet builds a file name for it:
String path = sc.getRealPath("/files");
// path is now C:\TOMCAT\webapps\MyWebApps\files\
fi.write(new File(path, fi.getName()));
// append myfile.zip to "path", making it C:\TOMCAT\webapps\MyWebApps\files\myfile.zipIE, however, tells "here comes the file C:\WINDOWS\Desktop\myfile.zip". Now imagine what the path+filename ends up being...
So what you want to do is something along the lines of (assuming Windoze):
public static String basename(String filename)
int slash = filename.lastIndexOf("\\");
if (slash != -1)
filename = filename.substring(slash + 1);
// I think Windows doesn't like /'s either
int slash = filename.lastIndexOf("/");
if (slash != -1)
filename = filename.substring(slash + 1);
// In case the name is C:foo.txt
int slash = filename.lastIndexOf(":");
if (slash != -1)
filename = filename.substring(slash + 1);
return filename;
fi.write(new File(path, basename(fi.getName()));
....You can make the file name check more bomb proof if security is an issue. Long file names trying to overflow something in the OS, NUL characters, Unicode, forbidden names in Windos (con, nul, ...), missing file name, ... -
Help with File Upload manually
Hi Experts,
I need code to upload a file without using the upload UI Element. we have our terms and conditions which has to be signed by the user and once the user signs and clicks the next button to go to the next page, I generate a pdf with the time stamp of when the user signed and upload it to ECC. here i can not use the File upload UI Element but have to upload it automatically to ECC.
Can any one help me out with this please.
ThanksHi,
I dont know why you need to to upload the file for this requirement. You can simply store the user id and the timestamp in portal database table or in a ECC z table.
In case you definitely need to upload the file then you can use KM API to uploadthe file to portal KM folder
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a099a3bd-17ef-2b10-e6ac-9c1ea42af0e9?quicklink=index&overridelayout=true
but you need not use the upload feature in the example, instead just get the data from wd context and upload to KM.
Srini -
I was wondering if there's a kind of lightweight component for uploading files in JSF. I tried Oracle's ADF Faces, but besides it being a couple of megs it screwed up the HTML code in my pages and some Javascript functions wouldn't work. I saw a post here where someone created his own component but as it will have minor use in my app i'd like something packed so I can just add it on.
I only need to upload one file in my app, so maybe it's better to use a regular JSP and Servlet approach for this one. Suggestions or comments would be appreciated, thanks..I followed the examples in the chapter, but I needed a .tld file so I created one:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>file</short-name>
<uri>http://java.sun.com/upload</uri>
<display-name>JSF File Upload</display-name>
<description>File upload library fo JSF</description>
<tag>
<name>upload</name>
<tag-class>com.corejsf.UploadTag</tag-class>
<body-content>JSP</body-content>
<description>
Uploads the file.
</description>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>target</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
Its in WEB-INF and declared in web.xml, but I'm getting an error:
javax.faces.FacesException: Expression Error: Named Object: 'com.corejsf.Upload' not found.
There's no such class in the component, but the UploadTag returns "com.corejsf.Upload" in both getRenderedType() and getComponentType().
If someone has this working; help please!! -
Help with file upload Actionscript
I am trying to do a file upload using Actionscript and a
modified version of the tutorial found at:
http://tutorials.lastashero.com/2005/10/creating_a_file_upload_applica.html
When I call the function
fileRef.upload("
http://www.imgthis.com/upload_loader.php");
should that go to that page once it finishes, or how do I
force Flash to redirect the browser to that page passing the
uploaded file?
What am I missing here, or what else would anyone need to
help me?
Any help would be greatly appreciated thanks in advance!
Joshua AbtsIt seems as though the page is not being loaded after the
ActionScript upload command.
Why would my PHP script not be called from the upload
ActionScript? I even just did a simple one line redirect to see if
the PHP script was even being called and it didn't work.
What is the basis for getting the script to send the picture
to the PHP script as a post and using the $_FILES array?
Thanks,
Josh -
Help on File Upload on ATG Dynamo 5.6 (Servlet 2.2)
Hi,
I am using Apache Common FileUpload to upload a file on the server. It works well on Tomcat . I tried to port the same code on ATG Dynamo 5.6.1, I could not upload the files. After going deep into the problem, I got to know that Apache FileUpload has a dependancy of Servlet 2.3 Specs compliance.
While I checked the version of Servlet on ATG, it was 2.2.
Could somebody help me with the same.
I need some file upload utility that would work on ATG Dynamo.
Or atleast a way out would do.
Thanks and regards.....
KalpakTry to obtain an older version of the commons FileUpload utility if available, which is compatible with your desired version or you can use another utility that supports Servlets 2.0 provided by Oreilly Package...
The class MultipartRequest authored by oreilly that included in the package holds the whole nasty behind the scenes, here you are the link for the docs
http://www.stanford.edu/group/coursework/stanfordoki/oreilly/com.oreilly.servlet.MultipartRequest.html
And you can find the package, examples and the sources here
http://examples.oreilly.com/jservlet2/
Best Regards,
mohammed Sleem -
Need Help With File Matching Records
I need help with my file matching program.
Here is how it suppose to work: FileMatch class should contain methods to read oldmast.txt and trans.txt. When a match occurs (i.e., records with the same account number appear in both the master file and the transaction file), add the dollar amount in the transaction record to the current balance in the master record, and write the "newmast.txt" record. (Assume that purchases are indicated by positive amounts in the transaction file and payments by negative amounts.)
When there is a master record for a particular account, but no corresponding transaction record, merely write the master record to "newmast.txt". When there is a transaction record, but no corresponding master record, print to a log file the message "Unmatched transaction record for account number ..." (fill in the account number from the transaction record). The log file should be a text file named "log.txt".
Here is my following program code:
// Exercise 14.8: CreateTextFile.java
// creates a text file
import java.io.FileNotFoundException;
import java.lang.SecurityException;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import org.egan.AccountRecord;
import org.egan.TransactionRecord;
public class CreateTextFile
private Formatter output1; // object used to output text to file
private Formatter output2; // object used to output text to file
// enable user to open file
public void openTransFile()
try
output1 = new Formatter("trans.txt");
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 method openTransFile
// enable user to open file
public void openOldMastFile()
try
output2 = new Formatter("oldmast.txt");
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 method openOldMastFile
// add transaction records to file
public void addTransactionRecords()
// object to be written to file
TransactionRecord record1 = new TransactionRecord();
Scanner input1 = new Scanner(System.in);
System.out.printf("%s\n%s\n%s\n%s\n\n",
"To terminate input, type the end-of-file indicator",
"when you are prompted to enter input.",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter");
System.out.printf("%s\n%s",
"Enter account number (> 0) and amount.","? ");
while (input1.hasNext()) // loop until end-of-file indicator
try // output values to file
// retrieve data to be output
record1.setAccount(input1.nextInt()); // read account number
record1.setAmount(input1.nextDouble()); // read amount
if (record1.getAccount() > 0)
// write new record
output1.format("%d %.2f\n", record1.getAccount(), record1.getAmount());
} // end if
else
System.out.println("Account 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.");
input1.nextLine(); // discard input so user can try again
} // end catch
System.out.printf("%s %s\n%s", "Enter account number (> 0) ",
"and amount.","? ");
} // end while
} // end method addTransactionRecords
// add account records to file
public void addAccountRecords()
// object to be written to file
AccountRecord record2 = new AccountRecord();
Scanner input2 = new Scanner(System.in);
System.out.printf("%s\n%s\n%s\n%s\n\n",
"To terminate input, type the end-of-file indicator",
"when you are prompted to enter input.",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter");
System.out.printf("%s\n%s",
"Enter account number (> 0), first name, last name and balance.","? ");
while (input2.hasNext()) // loop until end-of-file indicator
try // output values to file
// retrieve data to be output
record2.setAccount(input2.nextInt()); // read account number
record2.setFirstName(input2.next()); // read first name
record2.setLastName(input2.next()); // read last name
record2.setBalance(input2.nextDouble()); // read balance
if (record2.getAccount() > 0)
// write new record
output2.format("%d %s %s %.2f\n", record2.getAccount(), record2.getFirstName(),
record2.getLastName(), record2.getBalance());
} // end if
else
System.out.println("Account 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.");
input2.nextLine(); // discard input so user can try again
} // end catch
System.out.printf("%s %s\n%s", "Enter account number (> 0),",
"first name, last name and balance.","? ");
} // end while
} // end method addAccountRecords
// close file
public void closeTransFile()
if (output1 != null)
output1.close();
} // end method closeTransFile
// close file
public void closeOldMastFile()
if (output2 != null)
output2.close();
} // end method closeOldMastFile
} // end class CreateTextFile--------------------------------------------------------------------------------------------------
// Exercise 14.8: CreateTextFileTest.java
// Testing class CreateTextFile
public class CreateTextFileTest
// main method begins program execution
public static void main( String args[] )
CreateTextFile application = new CreateTextFile();
application.openTransFile();
application.addTransactionRecords();
application.closeTransFile();
application.openOldMastFile();
application.addAccountRecords();
application.closeOldMastFile();
} // end main
} // end class CreateTextFileTest-------------------------------------------------------------------------------------------------
// Exercise 14.8: TransactionRecord.java
// A class that represents on record of information
package org.egan; // packaged for reuse
public class TransactionRecord
private int account;
private double amount;
// no-argument constructor calls other constructor with default values
public TransactionRecord()
this(0,0.0); // call two-argument constructor
} // end no-argument AccountRecord constructor
// initialize a record
public TransactionRecord(int acct, double amt)
setAccount(acct);
setAmount(amt);
} // end two-argument TransactionRecord constructor
// set account number
public void setAccount(int acct)
account = acct;
} // end method setAccount
// get account number
public int getAccount()
return account;
} // end method getAccount
// set amount
public void setAmount(double amt)
amount = amt;
} // end method setAmount
// get amount
public double getAmount()
return amount;
} // end method getAmount
} // end class TransactionRecord -------------------------------------------------------------------------------------------------
// Exercise 14.8: AccountRecord.java
// A class that represents on record of information
package org.egan; // packaged for reuse
import org.egan.TransactionRecord;
public class AccountRecord
private int account;
private String firstName;
private String lastName;
private double balance;
// no-argument constructor calls other constructor with default values
public AccountRecord()
this(0,"","",0.0); // call four-argument constructor
} // end no-argument AccountRecord constructor
// initialize a record
public AccountRecord(int acct, String first, String last, double bal)
setAccount(acct);
setFirstName(first);
setLastName(last);
setBalance(bal);
} // end four-argument AccountRecord constructor
// set account number
public void setAccount(int acct)
account = acct;
} // end method setAccount
// get account number
public int getAccount()
return account;
} // end method getAccount
// set first name
public void setFirstName(String first)
firstName = first;
} // end method setFirstName
// get first name
public String getFirstName()
return firstName;
} // end method getFirstName
// set last name
public void setLastName(String last)
lastName = last;
} // end method setLastName
// get last name
public String getLastName()
return lastName;
} // end method getLastName
// set balance
public void setBalance(double bal)
balance = bal;
} // end method setBalance
// get balance
public double getBalance()
return balance;
} // end method getBalance
// combine balance and amount
public void combine(TransactionRecord record)
balance = (getBalance() + record.getAmount());
} // end method combine
} // end class AccountRecord -------------------------------------------------------------------------------------------------
// Exercise 14.8: FileMatch.java
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.IllegalStateException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Formatter;
import java.util.FormatterClosedException;
import org.egan.AccountRecord;
import org.egan.TransactionRecord;
public class FileMatch
private Scanner inTransaction;
private Scanner inOldMaster;
private Formatter outNewMaster;
private Formatter theLog;
// enable user to open file
public void openTransFile()
try
inTransaction = new Scanner(new File("trans.txt"));
} // end try
catch (FileNotFoundException fileNotFoundException)
System.err.println("Error opening file.");
System.exit(1);
} // end catch
} // end method openTransFile
// enable user to open file
public void openOldMastFile()
try
inOldMaster = new Scanner(new File("oldmast.txt"));
} // end try
catch (FileNotFoundException fileNotFoundException)
System.err.println("Error opening file.");
System.exit(1);
} // end catch
} // end method openOldMastFile
// enable user to open file
public void openNewMastFile()
try
outNewMaster = new Formatter("newmast.txt");
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 method openNewMastFile
// enable user to open file
public void openLogFile()
try
theLog = new Formatter("log.txt");
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 method openLogFile
// update records
public void updateRecords()
TransactionRecord transaction = new TransactionRecord();
AccountRecord account = new AccountRecord();
try // read records from file using Scanner object
System.out.println("Start file matching.");
while (inTransaction.hasNext() && inOldMaster.hasNext())
transaction.setAccount(inTransaction.nextInt()); // read account number
transaction.setAmount(inTransaction.nextDouble()); // read amount
account.setAccount(inOldMaster.nextInt()); // read account number
account.setFirstName(inOldMaster.next()); // read first name
account.setLastName(inOldMaster.next()); // read last name
account.setBalance(inOldMaster.nextDouble()); // read balance
if (transaction.getAccount() == account.getAccount())
while (inTransaction.hasNext() && transaction.getAccount() == account.getAccount())
account.combine(transaction);
outNewMaster.format("%d %s %s %.2f\n",
account.getAccount(), account.getFirstName(), account.getLastName(),
account.getBalance());
transaction.setAccount(inTransaction.nextInt()); // read account number
transaction.setAmount(inTransaction.nextDouble()); // read amount
else if (transaction.getAccount() != account.getAccount())
outNewMaster.format("%d %s %s %.2f\n",
account.getAccount(), account.getFirstName(), account.getLastName(),
account.getBalance());
theLog.format("%s%d","Unmatched transaction record for account number ",transaction.getAccount());
} // end while
System.out.println("Finish file matching.");
} // end try
catch (NoSuchElementException elementException)
System.err.println("File improperly formed.");
inTransaction.close();
inOldMaster.close();
System.exit(1);
} // end catch
catch (IllegalStateException stateException)
System.err.println("Error reading from file.");
System.exit(1);
} // end catch
} // end method updateRecords
// close file and terminate application
public void closeTransFile()
if (inTransaction != null)
inTransaction.close();
} // end method closeTransFile
// close file and terminate application
public void closeOldMastFile()
if (inOldMaster != null)
inOldMaster.close();
} // end method closeOldMastFile
// close file
public void closeNewMastFile()
if (outNewMaster != null)
outNewMaster.close();
} // end method closeNewMastFile
// close file
public void closeLogFile()
if (theLog != null)
theLog.close();
} // end method closeLogFile
} // end class FileMatch-------------------------------------------------------------------------------------------------
// Exercise 14.8: FileMatchTest.java
// Testing class FileMatch
public class FileMatchTest
// main method begins program execution
public static void main( String args[] )
FileMatch application = new FileMatch();
application.openTransFile();
application.openOldMastFile();
application.openNewMastFile();
application.openLogFile();
application.updateRecords();
application.closeLogFile();
application.closeNewMastFile();
application.closeOldMastFile();
application.closeTransFile();
} // end main
} // end class FileMatchTest-------------------------------------------------------------------------------------------------
Sample data for master file:
Master file
Account Number Name Balance
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00
700 Suzy Green -14.22Sample data for transaction file:
Transaction file Transaction
Account Number Amount
100 27.14
300 62.11
300 83.89
400 100.56
700 80.78
700 1.53
900 82.17 -------------------------------------------------------------------------------------------------
My FileMatch class program above has bugs in it.
The correct results for the newmast.txt:
100 Alan Jones 375.31
300 Mary Smith 173.19
500 Sam Sharp 0.00
700 Suzy Green 68.09The correct results for the log.txt:
Unmatched transaction record for account number 400Unmatched transaction record for account number 900------------------------------------------------------------------------------------------------
My results for the newmast.txt:
100 Alan Jones 375.31
300 Mary Smith 111.08
500 Sam Sharp 0.00
700 Suzy Green -12.69My results for the log.txt
Unmatched transaction record for account number 700-------------------------------------------------------------------------------------------------
I am not sure what is wrong with my code above to make my results different from the correct results.
Much help is appreciated. Please help.From the output, it looks like one problem is just formatting -- apparently you're including a newline in log entries and not using tabs for the newmast output file.
As to why the numbers are off -- just from glancing over it, it appears that the problem is when you add multiple transaction values. Since account.combine() is so simple, I suspect that you're either adding creating transaction objects incorrectly or not creating them when you should be.
Create test input data that isolates a single case of this (e.g., just the Mary Smith case), and then running your program in a debugger or adding debugging code to the add/combine method, so you can see what's happening in detail.
Also I'd recommend reconsidering your design. It's a red flag if a class has a name with "Create" in it. Classes represent bundles of independant state and transformations on that state, not things to do. -
HI Masters , I need information for file upload program in web dynpro java
Hi masters,
i need some inforamtion and documentation on file upload program in web dynpro javaHi surya,
You can follow this procedure to upload the file
i) Take One Context Attribute named as "D1" of Type "binary".
ii) Take one FileUpload UI Element in the Layout Tab.
iii) Bind FileUpload UI Element's data Property to the taken Context Attribute. Here it is "D1".
iv) Take one Button UI Element in the Layout Tab named "Upload" and in the Action of that Button write the following Code.
v) The following code Generates one Folder in the Server & inside that Folder given file is Uploaded.
File ff=new File("FolderXYZ"); // Creates One Folder with the given Name ( Here Folder name is "FolderXYZ")
ff.mkdir();
try
byte b[]=null;
IWDAttributeInfo objAttinfo=null;
IWDModifiableBinaryType binType=null;
File f=null;
FileOutputStream fos=null;
if(wdContext.currentContextElement().getD1()!=null)
b=wdContext.currentContextElement().getD1();
objAttinfo=wdContext.getNodeInfo().getAttribute(IPrivateAttachView.IContextElement.D1);
binType=(IWDModifiableBinaryType)objAttinfo.getModifiableSimpleType();
f=new File(ff.getName()+"
"+binType.getFileName());
fos=new FileOutputStream(f);
fos.write(b);
fos.flush();
fos.close();
objMessageManager.reportSuccess("File uploaded to server");
} catch (Exception e)
objMessageManager.reportException("Unable to upload file to server, error is:"+e,false);
return;
The Uploaded file is stored in the folder & that folder is stored in the Server's following Path.
<Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0
You can access your Uploaded file from the following Path
<Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0\FolderXYZ
Regards
Sagar Ingalwar -
I Need Information Regarding File Upload?
Where can I get information regarding the File uploading packages in Portal. Is there a specification I can get a hold of. I know such a package exists, as it is used by portal itself. I just need to know where I can get hold of information as to what it is called and how to invoke it.
Suraj,
The APIs to do file upload are not public as of yet. We are looking into the feature right now. Currently, the only supported method of file upload is using the Web Interface.
You may find more information about this in the 9iAs Portal forum
Sue -
i have a brand new MuVo n200
i need help, i put my cd's in and everyhting and i filled it with songs ans i can play them and everything, but i hate thats itssorted in ABC order. i cannot figure how to put them so it is in order by the CD or the bandname.
please help.
message me on aim if you want [email][email protected]][email protected][/url]To group the songs into albums or artist groups, I would definitely suggest putting all the tracks from each album/group in its own folder on your PC and put the folder on the muvo in just the same way as you would put a single mp3. The player (in normal play mode) will then play each folder all the way through before moving on to the next one alphabetically (or numerically, if you put numbers at the start of the folder names) and you can then use 'skip folder' to skip through to find the particular album or artist you're looking for. Play around with the shuffle modes too - you can shuffle within folders or just shuffle everything if you want.
Tracks will normally be played alphabetically. To get them to play in order of track number, put numbers at the beginning of each file name. E.g.: file 'examplesong.mp3' would become '0_ examplesong.mp3' If you've got tonnes of songs and you're worried about it taking ages, the computer will do it for you! Click on 'my computer', then click on 'Muvo N200 media explorer'.. This shows the contents of your player. Choose a folder to reorder the songs in and click on it to display the songs. In the pictures along the top of the window, 4th from the right is an icon with a downward facing arrow and an A above a Z. Click on this, it's called 'custom sort'. You can then use the arrows at the bottom to change the order of your tracks to how you want them. Click OK, and they'll all be numbered in that order!
For instructions on how to create folders in mediasource, read the thread in this link:
http://forums.creative.com/creativelabs/board/message?board.id=dap&message.id=926
I don't think you can put folders within folders in the muvo, but just the one layer really helps organisation.
Hope that helps!
x Flaneur
PS- scroll down in the thread in the link: Jeremy CL was nice enough to give pictures in his instructions! If you'd like more help, type 'create folders' or something into the forum search as there's probably quite a lot of advice kicking about here!Message Edited by flaneur on 03-27-2005 :8 PM -
NEED HELP GETTING FILES FROM ITUNES ON ONE COMPUTER TO THE OTHER.
So I was using a PC to backup my iphone 5 to itunes; however, i just bought a macbook pro and it wont let me transfer the files from one computer to the other and i need help!
Click here and pick the option which best fits your situation.
(93771) -
I need help transferring files from a locked admin account
I was having trouble connecting to my school's wifi because I couldn't remember my admin password to authenticate the changes. I created a new admin account, and connected to the wifi. I didn't realize by doing this all of my files would be on the old admin account. Now I am completely locked out of the account, and need help getting my files off of it! Any ideas?
Migrating from PPC Macs to Intel Macs:
https://discussions.apple.com/docs/DOC-2295
http://support.apple.com/kb/HT4796
and this article:
http://www.macworld.co.uk/mac/news/?newsid=3444778&olo=email
Maybe you are looking for
-
HI there, i need some help please ..... I had a hard drive failure, external one, the i use to have all my music collection ( 550 gigas of music ) I got a new external HD and put there all the music the i had it back it up, .... same folders name, sa
-
How do i email a file (not picture) from dropbox on my nice new iphone 6?
Hi, i need to use my iphone for business emails - having just moved from android i'm not too familiar with ios8 but i cant find any way to attach files from various folders in dropbox or anywhere else for that matter other than predefined apple image
-
How to provide F1 & F4 helps for a newly created field.
I have to create a <b>currency field</b> in 0100 screen like skb1-waers. I have to provide F1 & F4 helps for that field. Shall I give screen name as SKB1-WAERS ? I have given as above . But the problem is when the Processor is processing a that scree
-
HT1583 What blank DVD disks are compatible with burning a film from Idvd on an applemac?
I have just finalized a project in imovie and this message came up on the screen - "Your project exceeds the maximum duration. To burn your DVD, change the encoder setting in the project info window". I have changed the encoder setting from best fit
-
DVD Drive only reads some DVDs
I can watch most of my DVDs perfectly. However, some DVDs that I put in will spin around awhile before a message pops up saying I inserted a blank DVD and then it will eject. The DVDs are all purchased/rented. There are no problems on other DVD playe