How to insert a ZIP file in the message body and display it as icons
how to attach an ZIP file as an inline attachment. whether its possible in java mail.
Stop asking the same thing over and over.
Keep the discussion in your original thread.
Similar Messages
-
I bought a mac air retina to replace a mac pro. How can I get all files of the back up and copy them to the new mac?
Mail window may be in the Full Screen mode.
Move the mouse pointer to the top right corner of the Mail window and hold it there.
Menu bar should drop down and click the blue double arrow icon.
Full Screen toggle shortcut: control + command + F -
HOw to create a text file in the given path and delete it after the use?
Hi all,
I am trying to create a text file at the given path and delete the created file after the use.
I am using following code.:
import java.io.*;
// write binary data as characters
public class RanIO {
public static void main(String f[])
// First illustrate append
String lineSep = "\n";
try {
File temp= new File("C:/Ash","cute.txt");
boolean ch=temp.createNewFile();
if(ch)
System.out.println("file created");
else
System.out.println("file Not created");
//writing to file
/* PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
p.print("Emp NO");
p.close();*/
// Open fileWriter in append mode
FileWriter fos = new FileWriter(temp, true);
BufferedWriter bw = new BufferedWriter(fos);
PrintWriter pw = new PrintWriter(fos);
double d=550;
// lineSep = System.getProperty("line.separator");
pw.print("Hello");
//pw.print( lineSep );
pw.print( d );
pw.close();
boolean det=temp.delete();
if(det)
System.out.println("File deleted");
else
System.out.println("File not deleted");
} catch (IOException ioe)
System.out.println( "Append IO error:" + ioe );
My problem:
1)
I am not able to write to the file. I want to know, where i am going wrong.
It is giving error message like
"Canot resolve Symbol: temp,"
But, FileWriter Constructor should accept a File type parameter.
here temp is a file parameter.
If i am not using file=new file();
i can't delete the file after the use. i.e if i use
PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
how can i delete cute.txt after the use?
2)
I am not able to write to the text file. file is created but, a blank file.
"Hello" is not written into the text file.
can anyone help me in this regard
Thanks in advance
AshviniThank you Ram,
But, i want to create a text file in Append mode.
for that i used
FileWriter fos = new FileWriter(temp,true); But, it is not accepting FileWriter constructor in
this format. if i use
FileWriter fos = new
FileWriter("c:/ash/cute.txt",true); it works fine. !!!!!Here's the javadoc
public FileWriter(File file,
boolean append)
throws IOExceptionConstructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
Parameters:
file - a File object to write to
append - if true, then bytes will be written to the end of the file rather than the beginning
Throws:
IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
Since:
1.4
Are you using jdk.13 or lower ?
>
ONe more doubt, Does flush method deletes a file?
if not, then i need to use
File temp=new File("c:/ash/cute.txt");
FileWriter fos = new FileWriter(temp,true); //which
is again a problem
if(temp.delete())
out.println("File is deleted");
}I don't know whether i am taking it wrong ! or
anything wrong with my coding ! but, after creating
and writing data into a text file. I must delete it
as it contains confidential informations.
Regards,
Thanks.'flush' writes to a file immediately. Else you should explicitly call 'flush' to write contents from buffer to underlying source.
javadoc again
PrintWriter
public PrintWriter(Writer out,
boolean autoFlush)Create a new PrintWriter.
Parameters:
out - A character-output stream
autoFlush - A boolean; if true, the println, printf, or format methods will flush the output buffer
cheers,
ram.
Question; What do you gain by opening a file, writing to it and deleting it in the same program ? -
Hi All,
I have a purpose in winforms to have a "notepad like" editor that saves what ever i type to a file on the hard drive and reads from based.
So what i have is a tab with a richtextbox docked to fill. I would like to have that richtextbox read from a file on the hard drive, then save the changes i type when i either click off the tab or live if possible.
I wills state that i am fairly new to the c# game and if this is possible and someone could post an example that would be awesome and totally appreciated.
Thanks,
jACFor those that are looking for the solution I went with here are the details
Reading the file:
// Wish List Section
wishListRichTextBox.ResetText();
string wlFolder = Application.StartupPath + "\\wishLists\\";
string wlPath = wlFolder + selectedProduct + ".rtf";
// Read from the text file and out put the results
try
{ // create directory if it does not exist
if (!Directory.Exists(wlFolder))
Directory.CreateDirectory(wlFolder);
} // create file if it does not exist
if (!File.Exists(wlPath))
File.Create(wlPath).Dispose();
var iStream = new FileStream(wlPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var sr = new System.IO.StreamReader(iStream);
var readData = sr.ReadToEnd();
wishListRichTextBox.Text = readData;
sr.Close();
// If the read fails then output the error message in the same section
catch (Exception ex)
wishListRichTextBox.Text = "Error: " + ex.Message;
Writing the file:
private void wishlistTabChanged(object sender, EventArgs e)
if(menuTabControl.SelectedTab != wishListTab){
if (productComboBox.SelectedIndex >= 0)
try
string wlFolder = Application.StartupPath + "\\wishLists\\";
string wlPath = wlFolder + productComboBox.SelectedItem + ".rtf";
var oStream = new FileStream(wlPath, FileMode.Open, FileAccess.Write, FileShare.Read);
oStream.SetLength(0);
var sw = new System.IO.StreamWriter(oStream);
sw.WriteLine(wishListRichTextBox.Text);
sw.Close();
catch (Exception ex)
MessageBox.Show("Wish list for " + productComboBox.Text + " save failed. \n\nError: " +
ex, "Wish List Save Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
I mainly used Ammar.Zaied thought
process on this. Thanks to everyone though, as you all pointed me in the right direction -
How can I save a file in the Downloads folder and automatically have it opened?
Often, I'd like to download a file, save it to my Downlaods folder and have it opened right away.
Currently, you can only decide between the two options "open" or "save to...". There's seemlingly no way Firefox can do both at once.
I know I can download it, open the downloads manager and open it manually. But when working with over a dozen documents a day, that doesn't quite do the trick.
In Chrome, you only have to click twice: Once for downloading and once for opening it from the download bar on the bottom of the screen. You do not have to open a download manager.Yeah, thanks but that's not what I was trying to ask.
I know that you can save and open a document by performing these three steps:
1. Confirming to save a file to the Downloads folder
2. Open the download manager by clicking the temporarily green arrow
3. Clicking on the downloaded file
What I would like to know is whether or not it is possible to have Firefox open a saved file ''automatically''. At the moment, if I choose to open it automatically, it is only saved to my temp folder.
It would be great though if it was saved to my Downloads folder ''and'' opened with the respective program on my pc. Is there a way to do this? -
How to insert an exe file in the mozilla plugins directory?
Hello i have developed an application program using vb.net and have created its exe file on deskstop. This program is supposed to be a mozilla plugin. How can i insert the exe file from deskstop in mozilla plugins directory?
See https://developer.mozilla.org/en/Plugins
-
How to send binary data in the message body
How can we send binary data in the message body that is base64 encoded? below are the requirements
Mime Header.
Mime-version: 1.0
Content-Type: application/octet_stream; name=test
Content-Transfer-Encoding: Base64
Submission must be named "test.sub" (lowercase)
Submission must be base64 mime-encoded
Submission must be sent in the body of the message (not as an attachment)
Only one submission per mail message
No other comments should be put in the body of the mail message (other than the submission)
I highly appreciate your help. If you can provide few examples, that will be very helpfull.
Thanks,
MadanUse Message.setContent to set the content, or use Message.setDataHandler with
a DataHandler constructed with a ByteArrayDataSource. If the content is not
"naturally" encoded in base64, you can enforce it by setting the Content-Transfer-Encoding
header to "base64". Any reasonable mail reader won't care what encoding you use, as
long as the decoded data is correct. -
How do I move aiff files from the viewer to the timeline-it is not working when I click and drag or when I try to move the files to the overwrite or insert buttons-Thanks.
hi
You cannot move audio from the viewer
Mark your in and out points then in the browser grab hold of the audio tracks icon and drag that to the time line
PJ -
How to insert an image file in Oracle database
hi
can you please tell me how to insert an image file into oracle database????
suppose there is one image file in c:\pictures\rose.jpg. how to insert that file into database? theoretically i know that will be BFILE type but i dont know how to insert that.
will be waiting for your reply........
thanks & regards,
PriyatoshHello,
The easiest way to load a blob is to use SQL loader.
This example comes from the utilities guide:
LOAD DATA
INFILE 'sample.dat'
INTO TABLE person_table
FIELDS TERMINATED BY ','
(name CHAR(20),
1 ext_fname FILLER CHAR(40),
2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
Datafile (sample.dat)
Johny Quest,jqresume.txt,
Speed Racer,'/private/sracer/srresume.txt',
Secondary Datafile (jqresume.txt)
Johny Quest
500 Oracle Parkway
Secondary Datafile (srresume.txt)
Loading LOBs
10-18 Oracle Database Utilities
Speed Racer
400 Oracle Parkway
regards,
Ivo -
How to insert a image file into oracle database
hi all
can anyone guide me how to insert a image file into oracle database now
i have created table using
create table imagestore(image blob);
but when inserting i totally lost don't know what to do how to write query to insert image fileHi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
out.println(" <input type='submit' name='submit' value='Submit' class='smalltext'>");
out.println("</form>"); Import this once you have the jar file:
import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
boolean result = true;
String fileName = null;
byte fileData[] = null;
String fileUploadError = null;
String imageType = "";
String error = "";
DiskFileUpload fb = new DiskFileUpload();
List fileItems = fb.parseRequest(request);
Iterator it = fileItems.iterator();
while(it.hasNext()){
FileItem fileItem = (FileItem)it.next();
if (!fileItem.isFormField()) {
fileName = fileItem.getName();
fileData = fileItem.get();
// Get the imageType from the filename extension
if (fileName != null) {
int dotPos = fileName.indexOf('.');
if (dotPos >= 0 && dotPos != fileName.length()-1) {
imageType = fileName.substring(dotPos+1).toLowerCase();
if (imageType.equals("jpg")) {
imageType = "jpeg";
String filePath = request.getParameter("FILE_PATH");
session.setAttribute("filePath", filePath);
session.setAttribute("fileData", fileData);
session.setAttribute("fileName", fileName);
session.setAttribute("imageType", imageType);
return result;
} And now finally the method to actually write the file to the database:
private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
//If the previous code found a file that can be uploaded then
//save it into the database via a pstmt
String sql = "";
UtilDBquery udbq = getUser(request).connectToDatabase();
Connection con = null;
int signatureID = 0;
PreparedStatement pstmt = null;
try {
udbq.setUsePreparedStatements(true);
con = udbq.getPooledConnection();
con.setAutoCommit(false);
if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while(rs.next()) {
signatureID = rs.getInt(1);
if (fileName != null && imageType != null) {
sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
InputStream is2 = new ByteArrayInputStream(fileData);
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, signatureID);
pstmt.setBinaryStream(2, is2, (int)(fileData.length));
pstmt.executeUpdate();
pstmt.close();
con.commit();
con = null;
if(mode.equals("U") && signatureIDIn != 0) {
signatureID = signatureIDIn.intValue();
if (fileName != null && imageType != null) {
sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
InputStream is2 = new ByteArrayInputStream(fileData);
pstmt = con.prepareStatement(sql);
pstmt.setBinaryStream(1, is2, (int)(fileData.length));
pstmt.setInt(2, signatureID);
pstmt.executeUpdate();
pstmt.close();
con.commit();
con = null;
} catch (Exception e) {
con = null;
throw new Exception(e.toString());
return signatureID;
} -
I installed a version of 6.0. In the Russian program of social network My World by sending a short message, I can not insert a file in the message or photo. How do I solve this key problems?
I need to access Network Solutions website builder too. It isn't compatible with Internet Explorer v9, Chrome v13, or Firefox v5! I believe Firefox v6 is out now. This is a Network Solution's problem. What's involved in rolling back? Can you still get add-ons, plugins, and extensions for such an older version? You can't save your personal preferences can you?
-
How to insert a pdf file from a dynamic location into a table
Hi friends
Can any one please let me know how to insert a pdf file into a table from a dynamic location in server.
suppose say i have a table CUST_BLOB(file_name, file_data). I have a file in directory c:\local having file_name test.pdf
I want to insert this file in CUST_BLOB. Please help me.
Thanks in advance.
--Ahmeduser620950 wrote:
Hi friends
Can any one please let me know how to insert a pdf file into a table from a dynamic location in server. Why dynamic locations on the server?
Make it a business case that the files should be stored in specific location(s).
Oracle uses directory objects to point to locations on the file system and, whilst these locations can be altered, it is better practice to set up specific locations and grant permission to the correct users for those locations so that there is full control over who is accessing what on the server. Whilst filenames may be dynamic, I wouldn't recommend using dynamic locations. -
How to attach a PDF file TO the form so that recipients can access the file as a resource?
How to attach a PDF file TO the form so that recipients can access the file as a resource?
Sorry we do not support this. What you can do though is add a Formatted Text element and add a link to a PDF. To insert a link add some text, select the text and right click on the text (or look under the Insert menu in the top right of the scene)
Gen -
How to insert a gif file into a table?
Hi,
I need to insert a gif file into a table. Can anyone tell me where I can find the information on how to create this kind of table, how to insert a gif file into a table and how to select?
Thanks,
HelenHi Helen,
You could read about that in the documentation which is available online.
For a starter: BLOB. And I bet there are many examples to be found on the web.
Good luck. :)
Regards,
Guido -
How to check & unzip zip file using java
Dear friends
How to check & unzip zip file using java, I have some files which are pkzip or some other zip I want to find out the type of ZIp & then I want to unzip these files, pls guide me
thanksHow to check & unzip zip file using java, I have
ve some files which are pkzip or some other zip I
want to find out the type of ZIp & then I want to
unzip these files, pls guide meWhat do you mean "other zip"? Either they're zip archives or not, there are no different types.
Maybe you are looking for
-
Authenticating a user using AJAX
Hi, I'm building a login region and would like to build in the authentication process so that a new developer in a team can simply create on of our apps and just create a page that uses this region plugin. Is this possible to do in a single plugin? A
-
Using Attachments in the Email Adapter
Hi, I'm using an email adapter(Sender - XIPayload) to send message to XI. It was working fine when my mail content was the XML messsage. But now i have to use the content of an attachment file to do the mapping. The attachment is an XML file. I have
-
Is there a big differnce when you check "include full-resolution photos"
I was wondering the major difference, becuase if I wanted to transfer the images from the ipod to another device, would that be the right way, and will the full res pics take up to much space on the ipod hard drive. also how much compression is used
-
Wireless Issues with Apple TV 2nd generation
I have a linksys wireless router using WPA2 wireless security. I have 5 laptops, 2 printers, 3 iPhones, and 2 iTouch's connected to the wireless with no problem. My apple TV (second generation) has wireless issues, it will sit and connect and disco
-
Nokia N79 : Firmware Update
Hi. Does anyone know whether there will be a firmware update for Nokia N79 soon? Its been almost 8 months since the last one. I'm on v 32.001 and there has been no update thus far. Kindly let me know. Thanks in advance.