// This Fucntion will decode an entity to its original character
alert(textToEntity('<&>')); // returns <&>
@media print {
.printHide {
display:none;
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<style>
@media print {
.printHide {
display:none;
}
}
</style>
</HEAD>
<BODY>
<a href="javascript:void(0);" onclick="window.print();"
class="printHide">Print This Page</a>
<p>
Text Text Text Text Text
Text Text Text Text Text
</p>
<p>
Text Text Text Text Text
Text Text Text Text Text
</p>
</BODY>
</HTML>
For that we need to generate Class-Path attribute in the MANIFEST.MF dynamically. The following code shows how to do that.
1. Define a path element say, classpath
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
2. Convert the path element values into relative path and store it in a string property, say jar.classpath
<pathconvert property="jar.classpath" refid="classpath" pathsep=" ">
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.jar" to="lib/*.jar"/>
</chainedmapper>
</mapper>
</pathconvert>
<target name="jar" depends="clean,compile">
<mkdir dir="${jar.dir}"/>
<mkdir dir="${jar.lib.dir}"/>
<!-- Copying the external libraries to build/jar/lib folder. -->
<copy todir="${jar.lib.dir}">
<fileset dir="${lib.dir}" excludes="**/*.svn"/>
</copy>
<jar destfile="${jar.dir}/${jar.file}" basedir="${classes.dir}" excludes="**/*.svn">
<manifest>
<attribute name="Class-Path" value=". ${jar.classpath}" />
</manifest>
</jar>
</target>
Note :- The lib directory with the external jar files should be in the same directory as that of the project jar file.
We can't put the external jar files inside the project jar files with the above method.
Can you resuse a Thread Object? Can you restart it by calling start() again?
No. Once a thread's run() method has completed, the thread can never be restarted. In fact, at that point the thread moves into a state - dead. In dead state, the thead has finished its run()method and can never be restarted. The Thread object might still be on the heap, as aliving object that you can call other methods on (if appropriate), but the Thread object has permanently lost its 'threadness'. In other words, there is no longer a seperate call stack, and the Thread object is no longer a thread. It's Just an object, at that point, like all other objects.
But there are design patterns for making a pool of threads that you can keep using to perform different jobs. But you don't do it by retsarting a dead thread.
Use java.util.Timer and java.util.TimerTask to Implement a scheduler in java.
The following are all the Timer methods you can use to schedule repeated executions of tasks:
schedule(TimerTask task, long delay, long period)
schedule(TimerTask task, Date time, long period)
scheduleAtFixedRate(TimerTask task, long delay, long period)
scheduleAtFixedRate(TimerTask task, Date firstTime, long period)
When scheduling a task for repeated execution, use one of the schedule methods when smoothness is important and a scheduleAtFixedRate method when time synchronization is more important.
schedule method is appropriate for activities where it is more important to keep the frequency accurate in the short run than in the long run.
While in scheduleAtFixedRate, each execution is scheduled relative to the scheduled execution time of the initial execution. If an execution is delayed for any reason (such as garbage collection or other background activity), two or more executions will occur in rapid succession to "catch up."
Call Timer.cancel() to stop the Timer.
Example:
public class AnnoyingBeep {
Toolkit toolkit;
Timer timer;
public AnnoyingBeep() {
toolkit = Toolkit.getDefaultToolkit();
timer = new Timer();
timer.schedule(new RemindTask(),
0, //initial delay
1*1000); //subsequent rate
}
class RemindTask extends TimerTask {
int numWarningBeeps = 3;
public void run() {
if (numWarningBeeps > 0) {
toolkit.beep();
System.out.format("Beep!%n");
numWarningBeeps--;
} else {
toolkit.beep();
System.out.format("Time's up!%n");
//timer.cancel(); //Not necessary because
//we call System.exit
System.exit(0); //Stops the AWT thread
//(and everything else)
}
}
}
...
}
We can use File.renameTo() method to move a file from one folder to another.
File file = new File("filename");
// Destination directory
File dir = new File("directoryname");
// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
if (!success) {
// File was not successfully moved
}
Windows XP
This procedure applies only if you are running a language version of Microsoft Windows XP that doesn't match the language you want to type.
Windows 2000
This procedure applies only if you are running a language version of Microsoft Windows 2000 that doesn't match the language you want to type.
The following sql is to create a tablespace after creation of a user schema and then alter the user schema to take the new tablespace as default.
It also changes the system defined tablespace 'temp' as the temporary tablespace for the user.
create tablespace pfss datafile '/u12/oradata/wcrsec01/PFSS.dbf' size 100m autoextend on next 50m maxsize 1000m;
create tablespace pfss_idx datafile '/u12/oradata/wcrsec01/PFSS_IDX.dbf' size 100m autoextend on next 50m maxsize 1000m;
alter user pfss default tablespace pfss temporary tablespace temp;
Alter user pfss quota unlimited on pfss_idx;
Alter user pfss quota unlimited on pfss;