This sample code shows the method to create a Zip file and add files to it. It uses ZipOutputStream to write zip file.
import java.io.*;
import java.util.zip.*;
public class ZipFileWrtExp {
public static void main(String[] args) {
try {
FileOutputStream fos = new FileOutputStream("C:\\MyZip.zip");
ZipOutputStream zos = new ZipOutputStream(fos);
ZipEntry ze= new ZipEntry("C:\\file1.txt");
zos.putNextEntry(ze);
zos.closeEntry();
ze= new ZipEntry("C:\\file2.txt");
zos.putNextEntry(ze);
zos.closeEntry();
zos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Source: java-tips.org
Thursday, December 31, 2009
Tuesday, December 29, 2009
Sample MAP complier in CICS.
This is the samle map complier, you can use this to compile the maps.
//MAPCOM@ JOB MSGCLASS=X,MSGLEVEL=(1,1),CLASS=A,
// REGION=5M,NOTIFY=&SYSUID
//STEP1 EXEC DFHMAPS,
// DSCTLIB='&HLQ.CICS.COPY',
// MAPLIB='&LOADHLQ.CICS.LOAD',
// MAPNAME='&MAPNAME'
//COPY.SYSUT1 DD DSN=&HLQ.CICS.BMS(MEMBER),DISP=SHR
//MAPCOM@ JOB MSGCLASS=X,MSGLEVEL=(1,1),CLASS=A,
// REGION=5M,NOTIFY=&SYSUID
//STEP1 EXEC DFHMAPS,
// DSCTLIB='&HLQ.CICS.COPY',
// MAPLIB='&LOADHLQ.CICS.LOAD',
// MAPNAME='&MAPNAME'
//COPY.SYSUT1 DD DSN=&HLQ.CICS.BMS(MEMBER),DISP=SHR
Labels:
Technology
Sunday, December 27, 2009
Listing the image formats that can be read and written
This Java tip illustrates a method of listing the image formats that can be read and written. The complete list of available readable and writeable formats can be retrieved by calling ImageIO.getReaderFormatNames() and ImageIO.getWriterFormatNames(). By default, the javax.imageio package can read GIF, PNG, and JPEG images and can write PNG and JPEG images.
// Get list of unique supported read formats
String[] formatNames = ImageIO.getReaderFormatNames();
formatNames = unique(formatNames);
// e.g. png jpeg gif jpg
// Get list of unique supported write formats
formatNames = ImageIO.getWriterFormatNames();
formatNames = unique(formatNames);
// e.g. png jpeg jpg
// Get list of unique MIME types that can be read
formatNames = ImageIO.getReaderMIMETypes();
formatNames = unique(formatNames);
// e.g image/jpeg image/png image/x-png image/gif
// Get list of unique MIME types that can be written
formatNames = ImageIO.getWriterMIMETypes();
formatNames = unique(formatNames);
// e.g. image/jpeg image/png image/x-png
// Converts all strings in 'strings' to lowercase
// and returns an array containing the unique values.
// All returned values are lowercase.
public static String[] unique(String[] strings) {
Set set = new HashSet();
for (int i=0; i String name = strings[i].toLowerCase();
set.add(name);
}
return (String[])set.toArray(new String[0]);
}
source:java-tips.org
// Get list of unique supported read formats
String[] formatNames = ImageIO.getReaderFormatNames();
formatNames = unique(formatNames);
// e.g. png jpeg gif jpg
// Get list of unique supported write formats
formatNames = ImageIO.getWriterFormatNames();
formatNames = unique(formatNames);
// e.g. png jpeg jpg
// Get list of unique MIME types that can be read
formatNames = ImageIO.getReaderMIMETypes();
formatNames = unique(formatNames);
// e.g image/jpeg image/png image/x-png image/gif
// Get list of unique MIME types that can be written
formatNames = ImageIO.getWriterMIMETypes();
formatNames = unique(formatNames);
// e.g. image/jpeg image/png image/x-png
// Converts all strings in 'strings' to lowercase
// and returns an array containing the unique values.
// All returned values are lowercase.
public static String[] unique(String[] strings) {
Set set = new HashSet();
for (int i=0; i
set.add(name);
}
return (String[])set.toArray(new String[0]);
}
source:java-tips.org
Labels:
Java,
Programming
Friday, December 25, 2009
cfobjectcache in CF
The main function is to clear the occupied memory
and free the memory space.Flushes the query cache.
Syntax:
Attribute Req/Opt Description
action Required clear:Clears queries from the cache in the Application scope
Source : http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b11.htm#wp2310692
and free the memory space.Flushes the query cache.
Syntax:
Attribute Req/Opt Description
action Required clear:Clears queries from the cache in the Application scope
Source : http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b11.htm#wp2310692
Labels:
Cold Fusion
Wednesday, December 23, 2009
Risks to e-mail
There are several inherent risks in the way e-mail functions. When you send e-mail to a recipient, it travels to an SMTP (Simple Mail Transfer Protocol) server either directly (if you’re using an e-mail client such as Outlook) or via a Web server (if you’re using Web-based mail, such as Hotmail). The recipient will receive your e-mail directly from the SMTP server or via a Web server.
During this journey, any unauthorized person can access your messages by exploiting vulnerabilities on the SMTP or Web servers. Your messages can be read and copied by anyone who has access to the computers and networks through which your messages travel. In fact, authorized system administrators on the SMTP servers can also read, copy, save, delete, and modify your messages before sending them on.
During this ‘eavesdropping’, it may be possible to gain access to your usernames and passwords. The mischief-monger can then wreak havoc by sending messages on your behalf. You may also receive messages from known e-mail IDs that have been created and sent by unauthorized users; such messages usually contain viruses, Trojans or ask you to reply to the message with sensitive personal information, such as bank-account or credit-card details.
What’s more, mail backups on SMTP servers store the e-mail in plain text; sometimes, messages that you sent or received years ago are easily available on these backups, long after you have deleted them.
The issues with e-mail are, therefore, manifold - the sender’s e-mail ID may be stolen and misused, without the recipient knowing about it; messages may be intercepted; or messages may be stored such that their content is easily accessible.
Encryption, digital signatures, and digital certificates are some ways of securing e-mail from these threats.
Ref:India syndicate
During this journey, any unauthorized person can access your messages by exploiting vulnerabilities on the SMTP or Web servers. Your messages can be read and copied by anyone who has access to the computers and networks through which your messages travel. In fact, authorized system administrators on the SMTP servers can also read, copy, save, delete, and modify your messages before sending them on.
During this ‘eavesdropping’, it may be possible to gain access to your usernames and passwords. The mischief-monger can then wreak havoc by sending messages on your behalf. You may also receive messages from known e-mail IDs that have been created and sent by unauthorized users; such messages usually contain viruses, Trojans or ask you to reply to the message with sensitive personal information, such as bank-account or credit-card details.
What’s more, mail backups on SMTP servers store the e-mail in plain text; sometimes, messages that you sent or received years ago are easily available on these backups, long after you have deleted them.
The issues with e-mail are, therefore, manifold - the sender’s e-mail ID may be stolen and misused, without the recipient knowing about it; messages may be intercepted; or messages may be stored such that their content is easily accessible.
Encryption, digital signatures, and digital certificates are some ways of securing e-mail from these threats.
Ref:India syndicate
Labels:
EMail
Monday, December 21, 2009
Reading an Image from a file, inputStream, or URL
This Java tip illustrates a method of reading an Image from a file, inputStream, or URL. This tip also includes displaying of an image on the screen. Further, javax.imageio package is used to read an image from a file. This example works only above J2SE 1.4.
Image image = null;
try {
File sourceimage = new File("source.gif");
image = ImageIO.read(sourceimage);
InputStream is = new BufferedInputStream(
new FileInputStream("source.gif"));
image = ImageIO.read(is);
URL url = new URL("http://java-tips.org/source.gif");
image = ImageIO.read(url);
} catch (IOException e) {
}
JFrame frame = new JFrame();
JLabel label = new JLabel(new ImageIcon(image));
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
Ref: java-tips.org
Image image = null;
try {
File sourceimage = new File("source.gif");
image = ImageIO.read(sourceimage);
InputStream is = new BufferedInputStream(
new FileInputStream("source.gif"));
image = ImageIO.read(is);
URL url = new URL("http://java-tips.org/source.gif");
image = ImageIO.read(url);
} catch (IOException e) {
}
JFrame frame = new JFrame();
JLabel label = new JLabel(new ImageIcon(image));
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
Ref: java-tips.org
Labels:
Java
Saturday, December 19, 2009
Need to know more about file extensions?
Its a very intresting site to search more about the file extensions….
There are just TOO many of them this days.
ComputerFileExtensions.com that seem to be a nice resource for file extension and file formats.
On that site there exist a big database of all kind of file extensions you may come across and a good search facility to make it easier to find any file type you may looking for. I found there MXML and as too. Anyway, there is a way to see details on each file extension and it tells that extension.
There are just TOO many of them this days.
ComputerFileExtensions.com that seem to be a nice resource for file extension and file formats.
On that site there exist a big database of all kind of file extensions you may come across and a good search facility to make it easier to find any file type you may looking for. I found there MXML and as too. Anyway, there is a way to see details on each file extension and it tells that extension.
Labels:
Files
Thursday, December 17, 2009
Compiling Flex application from command line
Prerequisites:
1. If Flex builder is not installed download Flex 3 SDK from http://www.adobe.com/products/flex/flexdownloads/index.html#sdk
2. Unzip it to c:\adobe\. In this case installDir = c:\adobe\
3. If Flex builder 3 is already installed check the install directory. Assuming installDir = c:\Adobe\
4. Java should be installed in the system.
5. Flash player should be installed in the system.
Creating and compiling Flex Application:
Open notepad or any editor and copy the code below:
http://www.adobe.com/2006/mxml" layout="vertical" width="100%" height="100%">
1. Save it as Text.mxml in c:\temp\
2. Open command prompt window.
3. installDir\sdks\3.x.x\bin\mxmlc.exe c:\temp\Test.mxml (installDir = c:\adobe)
4. It should be compiled to Test.swf in c:\temp
1. If Flex builder is not installed download Flex 3 SDK from http://www.adobe.com/products/flex/flexdownloads/index.html#sdk
2. Unzip it to c:\adobe\. In this case installDir = c:\adobe\
3. If Flex builder 3 is already installed check the install directory. Assuming installDir = c:\Adobe\
4. Java should be installed in the system.
5. Flash player should be installed in the system.
Creating and compiling Flex Application:
Open notepad or any editor and copy the code below:
1. Save it as Text.mxml in c:\temp\
2. Open command prompt window.
3. installDir\sdks\3.x.x\bin\mxmlc.exe c:\temp\Test.mxml (installDir = c:\adobe)
4. It should be compiled to Test.swf in c:\temp
Labels:
Technology
Tuesday, December 15, 2009
MVS SYSTEM CODES -S80A
The storage needed to execute the program was not available.
1. The region parameter did not specify enough storage.
2. The region parameter was omitted, and the default storage amount was too small to run the correct program.
3. Block sizes were increased or buffers were added, and the region size was not increased.
4. A logic error caused excessive storage to be obtained but not freed.
1. Increase the region size.
2. Look for logic errors which may cause excessive calls to other programs or requests for storage.
Ref: www.ibmmainframes.com
1. The region parameter did not specify enough storage.
2. The region parameter was omitted, and the default storage amount was too small to run the correct program.
3. Block sizes were increased or buffers were added, and the region size was not increased.
4. A logic error caused excessive storage to be obtained but not freed.
1. Increase the region size.
2. Look for logic errors which may cause excessive calls to other programs or requests for storage.
Ref: www.ibmmainframes.com
Labels:
Mainframes
Sunday, December 13, 2009
Digital IDs and Signatures
Having a digital ID enables you to add another layer of security to your e-mail via digital signatures. A digital ID ties your identity information—name or e-mail ID, for instance—with your public key.
When you use this ID to digitally sign your messages, a part of your message is encrypted with your private key, so that the recipient knows that the message came from you; if you encrypt the message in addition, then the signature and the message are encrypted with your public key. This enables the recipient to know whether the message has been accessed or modified en route.
Digital IDs are provided via e-mail certificates, which are usually issued by external certification authorities (CAs). In organizations, sometimes, the administrator of your Exchange Server generates these certificates for users.
If you use Outlook, you can get e-mail certificates from CAs. Some like Comodo offer these free of charge for personal use; for commercial use, different schemes are available from various CAs. source:India syndicate
When you use this ID to digitally sign your messages, a part of your message is encrypted with your private key, so that the recipient knows that the message came from you; if you encrypt the message in addition, then the signature and the message are encrypted with your public key. This enables the recipient to know whether the message has been accessed or modified en route.
Digital IDs are provided via e-mail certificates, which are usually issued by external certification authorities (CAs). In organizations, sometimes, the administrator of your Exchange Server generates these certificates for users.
If you use Outlook, you can get e-mail certificates from CAs. Some like Comodo offer these free of charge for personal use; for commercial use, different schemes are available from various CAs. source:India syndicate
Friday, December 11, 2009
Concept of 3G
There will be a wide range, from simple single-application devices such as voice-only phones, to multi-purpose communicators capable of handling several voice, data and video services in parallel.
To date, the "terminal" for accessing mobile services has been the mobile phone. With the coming of 3G, we can expect to see a broadening of this concept to include a whole host of new terminals. These will be both general-purpose computing and communications devices, and devices with more specific purposes to serve particular marker segments. There will still be recognizable mobile phones. But many of these will have larger screens to display Internet pages or the face of the person being spoken to. There will be smaller "smart-phones" with limited web browsing and e-mail capabilities. The addition of mobile communications capabilities to laptop and palmtop computers will speed up the convergence of communications and computing, and bring to portable computing all the functions and features available on the most powerful desktop computers. There will be videophones, wrist communicators, palmtop computers, and radio modem cards for portable computers. Innovative new voice based interfaces will allow people to control their mobile communication services with voice commands.
We will also see the integration of 3G into a very wide range of devices and products other than user terminals. For example, the "telephone-on-a-card" will allow mobile services to be built into business equipment, vehicles and household appliances, for dedicated applications. Devices such as phones, computers and digital cameras will also be able to communicate with each other using short-range radio. Digital cameras will be able to use wide-area radio communications in real time and reduce the need for bulky memory and other components.
To date, the "terminal" for accessing mobile services has been the mobile phone. With the coming of 3G, we can expect to see a broadening of this concept to include a whole host of new terminals. These will be both general-purpose computing and communications devices, and devices with more specific purposes to serve particular marker segments. There will still be recognizable mobile phones. But many of these will have larger screens to display Internet pages or the face of the person being spoken to. There will be smaller "smart-phones" with limited web browsing and e-mail capabilities. The addition of mobile communications capabilities to laptop and palmtop computers will speed up the convergence of communications and computing, and bring to portable computing all the functions and features available on the most powerful desktop computers. There will be videophones, wrist communicators, palmtop computers, and radio modem cards for portable computers. Innovative new voice based interfaces will allow people to control their mobile communication services with voice commands.
We will also see the integration of 3G into a very wide range of devices and products other than user terminals. For example, the "telephone-on-a-card" will allow mobile services to be built into business equipment, vehicles and household appliances, for dedicated applications. Devices such as phones, computers and digital cameras will also be able to communicate with each other using short-range radio. Digital cameras will be able to use wide-area radio communications in real time and reduce the need for bulky memory and other components.
Labels:
Wireless
Wednesday, December 09, 2009
How to enable HOT deployment scanner in JBoss ?
Steps :
- Open the file $JBOSS_HOME/server/[Instance Name]/conf/jboss-service.xml
- Search for "ScanEnabled"
- The enable to the Hot deployment scanner as below
true - You can set the Automatic scan period for Hot deployment,
5000 - Restart the service once you made the changes.
Labels:
Server
Monday, December 07, 2009
cfupdate in CF
Updates records in a data source from data in a ColdFusion form or form Scope.
Syntax :
Attribute - description
dataSource- Name of the data source that contains the table. tableName- Name of table to update. tableOwner- For data sources that support table ownership tableQualifier- For data sources that support table qualifiers. username- Overrides username value specified in ODBC setup.password- Overrides password value specified in ODBC setup.formFields-Comma-delimited list of form fields to update.
Note :
If a form field is not matched by a column name in the database, ColdFusion throws an error.
The formFields lies must include the database table primary key field, which must be present in the form. It can be hidden.
Program :
SELECT Course_Number, Course_ID, DescriptFROM CoursesWHERE Course_ID = #Trim(url.Course_ID)# ORDER by Course_Number
Source : http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-c19.htm#wp1104662
Syntax :
Attribute - description
dataSource- Name of the data source that contains the table. tableName- Name of table to update. tableOwner- For data sources that support table ownership tableQualifier- For data sources that support table qualifiers. username- Overrides username value specified in ODBC setup.password- Overrides password value specified in ODBC setup.formFields-Comma-delimited list of form fields to update.
Note :
If a form field is not matched by a column name in the database, ColdFusion throws an error.
The formFields lies must include the database table primary key field, which must be present in the form. It can be hidden.
Program :
Source : http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-c19.htm#wp1104662
Labels:
Cold Fusion
Saturday, December 05, 2009
Saving a BufferedImage to a PNG file
You can save a BufferedImage object using write method of the javax.imageio.ImageIO class. The signutaure of the method is like this:
public static boolean write(RenderedImage im,
String formatName,
File output)
throws IOException
Here im is the RenderedImage to be written, formatName is the String containg the informal name of the format (e.g. png) and output is the file object to be written to. An example usage of the method for PNG file format is shown below:
ImageIO.write(image, "png", file);
You can also use getReaderFormatNames method of the same class to learn available informal format names understood by the current set of registered readers.
source: java-tips.org
public static boolean write(RenderedImage im,
String formatName,
File output)
throws IOException
Here im is the RenderedImage to be written, formatName is the String containg the informal name of the format (e.g. png) and output is the file object to be written to. An example usage of the method for PNG file format is shown below:
ImageIO.write(image, "png", file);
You can also use getReaderFormatNames method of the same class to learn available informal format names understood by the current set of registered readers.
source: java-tips.org
Labels:
Java
Thursday, December 03, 2009
Protecting Worksheet Names in Excel!!
If you are developing workbooks for others to use, you may want your worksheets to retain whatever names you give them. Excel normally allows users to change worksheet names, as desired. If you don't want them to change, the only way to prevent it is to lock the workbook. You can take these steps if you are using a version of Excel prior to Excel 2007:
1.Display the Review tab of the ribbon.
2.Click Protect Workbook in the Changes group. Excel displays the Protect Structure and Windows dialog box. (Click here to see a related figure.)
3.Make sure that the Structure check box is selected.
4.Enter a password in the Password box.
5.Click on OK. Excel displays the Confirm Password dialog box, prompting you to reenter the password.
6.Reenter the password and click on OK.
The user can no longer make changes to the names of the worksheet tabs, nor to anything else that affects the structure of the workbook. (For instance, they cannot enter new worksheets or delete existing ones.)
If you want to protect the workbook under the control of a macro, then you can use this code:
ActiveWorkbook.Protect Password:="MyPassword", Structure:=TrueAll you need to do is provide password you want to use in place of the "MyPassword" example.
Source: http://excel2007.tips.net/Pages/T0102_Protecting_Worksheet_Names.html
1.Display the Review tab of the ribbon.
2.Click Protect Workbook in the Changes group. Excel displays the Protect Structure and Windows dialog box. (Click here to see a related figure.)
3.Make sure that the Structure check box is selected.
4.Enter a password in the Password box.
5.Click on OK. Excel displays the Confirm Password dialog box, prompting you to reenter the password.
6.Reenter the password and click on OK.
The user can no longer make changes to the names of the worksheet tabs, nor to anything else that affects the structure of the workbook. (For instance, they cannot enter new worksheets or delete existing ones.)
If you want to protect the workbook under the control of a macro, then you can use this code:
ActiveWorkbook.Protect Password:="MyPassword", Structure:=TrueAll you need to do is provide password you want to use in place of the "MyPassword" example.
Source: http://excel2007.tips.net/Pages/T0102_Protecting_Worksheet_Names.html
Tuesday, December 01, 2009
Adobe squeezes AIR out of beta for Linux users
Adobe just released the beta version of Adobe AIR for Linux on Adobe Labs!
This Labs release of AIR has all features implemented for Linux, except support for DRM and badge installations. Major new features include support for system tray icons, keyboard shortcuts, localization, internationalized input (IME support), filetype registration, SWF and PDF in HTML, multi-monitor support, fullscreen mode, encrypted local storage, support for V4L2 cameras and printing.
The list of supported distributions has also been updated to:
1. Ubuntu 7.10
2. Fedora 8
3. OpenSuSE 10.3
Any AIR application that works on Windows/Mac AIR release version 1.1 should ideally work on Linux too
This Labs release of AIR has all features implemented for Linux, except support for DRM and badge installations. Major new features include support for system tray icons, keyboard shortcuts, localization, internationalized input (IME support), filetype registration, SWF and PDF in HTML, multi-monitor support, fullscreen mode, encrypted local storage, support for V4L2 cameras and printing.
The list of supported distributions has also been updated to:
1. Ubuntu 7.10
2. Fedora 8
3. OpenSuSE 10.3
Any AIR application that works on Windows/Mac AIR release version 1.1 should ideally work on Linux too
Labels:
Linux
Subscribe to:
Posts (Atom)