How to know if an object is a File or a Folder ?
Hello again,
I am looking for an easy method to determine whether a File or Folder object point to an actual file or to a folder. Both objects seem to have the same set of properties, except the File element has more. But the Data Browser in the ESTK refuses to show the contents of a File object when I have not actively retrieved the properties yet. Is this simply a matter of testing whether a file-related property exists in the object? Is there another, more elegant method, an undocumented feature, for instance a property IsFolder or something similar ?
Ciao
Jang
Hi Jang,
This from Chapter 3 of the JavaScript Tools Guide:
There are several ways to distinguish between a File and a Folder object. For example:
if (f instanceof File) ...
if (typeof f.open == "undefined") ...// Folders do not open
File and Folder objects can be used anywhere that a path name is required, such as in properties and arguments for files and folders.
Rick
Similar Messages
-
How do I stop LR4 from organizing imported files into a folder by date.
How do I stop LR4 from organizing imported files into a folder by date. Most times when I import files I have already created a folder and sub-folder structure tyat I want to use. I then right click the desired folder and choose import into this folder option. Why does LR4 insist on organizing my already selected destination into a sub-folder with a date by default?
TimHillPhotography23 wrote:
Most times when I import files I have already created a folder and sub-folder structure tyat I want to use.
If you do it this way all the time consider a different approach:
Manually copy your images from the card into your desired destination folder in the Finder/Explorer. Once complete drag&drop that entire folder into Lightroom. When the import dialog pops up select to Add the images to the catalog (not copy or move). You will end up with the exact folder structure reflected in your library. -
How to know corresponding info object for R/3 field and viceversa
Hi....
How to know corresponding object for a filed in r/3 data source and viceversa..While defining transformations.
We can't do mapping of all objects to fields with the definition......!!!
In 'rsosfieldmap'' what information we should give to know the proper tranformation...?
thank u.....Hi,
There are two ways to know the corresponding info objects in R/3 fields:
1) goto se11 t-code, enter RSOSFIELDMAP and enter display button. in the next screen click contents and give the field name or info object name as per your requirement, and excute.
2) first go through the field description in r/3 and identify the similar description in BI. For your easy understanding use excel sheet , in that you can copy the data source fields and target info objects ( master data or transaction data ). then it will be easy to identify the similar description.
Thank you. -
How to know when an object is deleted?
Hi,
In Java, instances of classes are eliminate by garbage collector and programmers have no chance to do it.
I need to do something, when the instance of a class ends its cycle-life .
How do I know when an object is going to be deleted, in order to make some thing bounded to this event?
thank you
Regards
AngeloThank you for your help ...
Here some code (I hope that I didn't forget something important):
1. A class inside the JaveaBeans to manage events:
* NavBean_EventsBroadcaster is a singleton class used in the JavaBean to manage (fire)
* the events; and also to manage (add/remove) the listeners.
* Events are raised when users push buttons with the purpose to change the display of
* records (of the table) on the screen.
public class NavBean_EventsBroadcaster implements Serializable {
private transient Vector listeners;
private static NavBean_EventsBroadcaster eventsBroadcaster_ForNavBeans = null;
Method to get the instance of the singleton class
static public NavBean_EventsBroadcaster getSingletonInstance() {
if (eventsBroadcaster_ForNavBeans == null) {
eventsBroadcaster_ForNavBeans = new NavBean_EventsBroadcaster();
return eventsBroadcaster_ForNavBeans;
} // getSingletonInstance
* fireTheEvent_X_navBean(): method that raise events
public void fireTheEvent_X_navBean(
Object source,
NavigatorBean_eventsList_ENUM nbEvtENUM,
ResultSet rst,
int keyReg) {
if (listeners != null && !listeners.isEmpty()) {
// object is going to be created (it contains the infos about the event)
NavBeanDB_EventDescriptor event_descr =
new NavBeanDB_EventDescriptor(
source, // dBbeanNavigator
nbEvtENUM,
rst,
keyReg);
// copy of the lisener to use it for add or remove
Vector targets;
synchronized (this) {
targets = (Vector) listeners.clone();
// proper event (select first, next, prev, last reg) is raised
Enumeration enumerat = targets.elements();
while (enumerat.hasMoreElements()) {
NavBeanDBListener_INTERFACE l =
(NavBeanDBListener_INTERFACE) enumerat.nextElement();
l.firedNavigationBeanEvents(event_descr);
System.out.println("Method fireTheEvent ----- key = " + priKeyOnTheScreen);
} // if
} // fireTheEvent()
* Adds a listener to the listener list.
* @param l The listener to add.
synchronized public void addNavBeanAddListener(NavBeanDBListener_INTERFACE l) {
if (listeners == null) {
listeners = new Vector();
listeners.addElement(l);
System.out.println("E' stato registrato un nuovo ascoltatatore per navigationBar");
} // addNavBeanAddListener()
* Removes a listener from the listener list.
* @param l The listener to remove.
synchronized public void removeNavBeanRemoveListener(NavBeanDBListener_INTERFACE l) {
if (listeners.contains(l)) {
listeners.remove(l);
} // removeNavBeanRemoveListener()
} // class NavBean_EventsBroadcaster2. The used interface
* This is the interface that specifies the contract between a NavBeans
* source and listener classes.
* @author Owner
public interface NavBeanDBListener_INTERFACE extends EventListener {
public void firedNavigationBeanEvents(NavBeanDB_EventDescriptor evt);
} // interface NavDB_BeansListener_INTERFACE3. the class adapter
public abstract class DbNavigatorBean_Adapter implements NavBeanDBListener_INTERFACE {
NavigatorBean_eventsList_ENUM navigatorBean_eventsList_ENUM;
public DbNavigatorBean_Adapter() { // costruttore
} // costruttore
* This class have to be implemented from listeners to get events.
* @param evt
// NavigatorBean_eventsList_ENUM {user_chang, sequential_first, sequential_prev, sequential_next, sequential_last}
public void firedNavigationBeanEvents(NavBeanDB_EventDescriptor evt) {
navigatorBean_eventsList_ENUM = evt.getEventType();
switch (navigatorBean_eventsList_ENUM) {
case user_chang:
toDoWhen_user_changeRegistration(evt);
break;
case sequential_first:
toDoWhen_setted_firstRegistration(evt);
break;
case sequential_prev:
toDoWhen_setted_prevRegistration(evt);
break;
case sequential_next:
toDoWhen_setted_nextRegistration(evt);
break;
case sequential_last:
toDoWhen_setted_lastRegistration(evt);
break;
} // witch case
} // firedNavigationBeanEvents()
abstract public void toDoWhen_user_changeRegistration(NavBeanDB_EventDescriptor evt); // { }
abstract public void toDoWhen_setted_firstRegistration(NavBeanDB_EventDescriptor evt); // { }
abstract public void toDoWhen_setted_nextRegistration(NavBeanDB_EventDescriptor evt); // { }
abstract public void toDoWhen_setted_prevRegistration(NavBeanDB_EventDescriptor evt); // { }
abstract public void toDoWhen_setted_lastRegistration(NavBeanDB_EventDescriptor evt); // { }
} // class class DbNavigatorBean_Adapter_base4. the class used to describe the event
Class used to dercribe the event that happened.
public class NavBeanDB_EventDescriptor extends EventObject {
private NavigatorBean_eventsList_ENUM navigationBean_events_ENUM;
private int primaryKeyOfRegOnTheScreen;
private ResultSet resultSet;
private int totOfRegsRegistredOnTheTable;
* Costructor: is used to describe the events
* @param source
* @param nbEvtENUM
* @param rst
* @param keyReg
public NavBeanDB_EventDescriptor( // costruttore
Object source,
NavigatorBean_eventsList_ENUM nbEvtENUM,
ResultSet rst,
int keyReg) {
super(source);
this.navigationBean_events_ENUM = nbEvtENUM;
this.resultSet = rst;
this.primaryKeyOfRegOnTheScreen = keyReg;
extractTotRegsInTheTable(rst);
// this.totOfRegsRegistredOnTheTable = rgsRegNmbr;
System.out.println("Viene creata una istanza di event descriptor");
}// costruttore
* which possibe action caused the event,
* was pushed the button (first, prev, next, last, user select...)
* @return
public NavigatorBean_eventsList_ENUM getEventType() {
return navigationBean_events_ENUM;
} // getEventType
* primmary key of registration on the screen
* @return
public int getPrimaryKeyOfTheRegOnTheScreen() {
return primaryKeyOfRegOnTheScreen;
} // getKeyRegOnTheScreen
* resultSet showed on the screen
public ResultSet getTheFullRegistrationOnTheScreen() {
return resultSet;
} // getTheFullRegistrationOnTheScreen
Number of registrations actually on the table.
public int getTotRegsRegistredOnTheTable() {
return this.totOfRegsRegistredOnTheTable;
} // getRegsRegistredNmbr
private classe that get data
private void extractTotRegsInTheTable(ResultSet rst) {
ResultSet localRst =rst;
try {
int curRow = localRst.getRow();
localRst.last();
this.totOfRegsRegistredOnTheTable = localRst.getRow();
localRst.absolute(curRow);
} catch (SQLException ex) {
Logger.getLogger(NavBeanDB_EventDescriptor.class.getName()).log(Level.SEVERE, null, ex);
} // class NavBeansEvent5. a possible use of the JavaBeans
public class TableClients extends JFrame
implements LinkTablesToDlgThatRandomizeSelections_INTERFACE {
private NavigationBean navigationBean;
public TableClients() { // constructor
navigationBean = new NavigationBean();
navigationBean.initializeDBbeanNavigator(...);
this.add(navigationBean);
navigationBean.addActionNavigatorListener(new DbNavigatorBean_Adapter() {
@Override
public void toDoWhen_user_changeRegistration(NavBeanDB_EventDescriptor nbdbed) {
// do something
@Override
public void toDoWhen_setted_firstRegistration(NavBeanDB_EventDescriptor nbdbed) {
// do something
@Override
public void toDoWhen_setted_nextRegistration(NavBeanDB_EventDescriptor nbdbed) {
// do something
@Override
public void toDoWhen_setted_prevRegistration(NavBeanDB_EventDescriptor nbdbed) {
// do something
@Override
public void toDoWhen_setted_lastRegistration(NavBeanDB_EventDescriptor nbdbed) {
// do something
} // constructor
} // class TableClientsthis code works well...
But if I implement the javaBeans on more than one Dialogs (windows) and the user uses
this dialogs sequentially, then the JavaBean responds to the events always as the caller is the
first dialog that run...
If I delete all listener (on the dialog) when the dialog is close then I have not problems
still thank you
Regards
Angelo -
How to know the workflow object name assigned to a Transaction code
Hi Friends,
There is one workflow object assigned to one transaction code VKM1. How can i know the workflow object name assigned to that particular transaction. Can anybody help me?
Regards
shankarHI
Please check t.code PPOMW
Thanks & Regards
Phaneendra -
Hibernate: How to know if an object is dirty in an update
Hi everyone:
I've looked around and I haven't found the solution for this, even asking in a hibernate forum, so maybe you know about this.
I want to know if an object is dirty before updating it to add a history record in every update. Hibernate does it automatically but I would like to know whether is dirty or not. I've seen in the book that we can do something like that with an interceptor but then I've seen this:
findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Do I have to set all these parameters everytime I call the method? Or does hibernate give us a tool or method to know the previous state of the object, the property names and the types?
Thank you very much in advance for your attentionThanks, Mohammed, For your reply. Would appreciate if you can suggest if some inbuilt package is available to retrieve the payvalue for an element for any given period..
Thanks again for your time!! -
How to save a properties object to a file / how to create a properties file
hi,
i am writing an application in which all the database and user information is stored in a properties object and is later retreived from it when a database connection or login etc is required.
i wanna know how can i save this object / write it to a file i.e. how do i create a properties file.
so that every time the application is run to create a new dbase etc the entire info regarding that will be stored in a new property file.Load:
Properties p = new Properties();
FileInputStream in = new FileInputStream("db.properties");
p.load(p);
String username = p.getProperty("username");
String password = p.getProperty("password");
// ...Save:
String username = "user";
String password = "pw";
Properties p = new Properties();
p.setProperty("username", username);
p.setProperty("password", password);
FileOutputStream out = new FileOutputStream("db.properties");
p.store(out, null); // null or a String header as second argumentThe file will look something like
username=user
password=pw -
How to continue to read Object from a file?
At some program I write an object into a file. This program will be called again and again so that there are many objects which are saved to that file. And I write another program to read object from this file. I can read the first object but can not read the second. However if I delete the object in that file (using editplus, by manually) I can read the second. Because now the second object is the first object. (Delete first object).
The exception when I read the second object is below:
java.io.StreamCorruptedException: Type code out of range, is -84
at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1607)
at java.io.ObjectInputStream.refill(ObjectInputStream.java:1735)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:319)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:272)
at LogParser.main(LogParser.java:42)
Exception in thread "main" The read object from file program is below:
public static void main(String[] args) throws Exception {
FileInputStream fis = new FileInputStream(path + File.separator + "ErrorApp21config2.log");
ObjectInputStream ois = new ObjectInputStream(fis);
ErrorLog errorLog = (ErrorLog)ois.readObject();
System.out.println(errorLog.getErrorDate());
FIFData fifData = (FIFData)errorLog.getErrorDescription();
CommRegistration commRegistration = (CommRegistration)
fifData.getDataObject(FIFData.REGISTRATION_DATA);
String ic = commRegistration.getPatient().getPatExtID();
System.out.println(ic);
CommQueue commQueue = (CommQueue) fifData.getDataObject(FIFData.QMS_DATA);
String location = commQueue.getLocation();
System.out.println(location);
ois.readObject(); //will throw above exception
fis.close();
}Can anyone tell me how to continue to read object? Or I should do some special things when I write object into file?Thanks Jos.
Perhaps you are correct.
There are some code in a SessionBean to log an object. Write file code is below.
private void logPreRegError(
byte[] strOldFifData,
byte[] strNewFifData,
String requestID)
throws TTSHException {
if (requestID.equals(RequestConstants.ADMIT_PATIENT)){
String runtimeProp = System.getProperty("runtimeproppath");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(
runtimeProp + File.separator + "Error.log", true);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(strOldFifData);
bos.write(strNewFifData);
bos.flush();
} catch (FileNotFoundException e) {
log(e);
} catch (IOException e) {
log(e);
} finally{
if (fos != null){
try {
fos.close();
} catch (IOException e1) {
log(e1);
}strOldFifData and strNewFifData are the byte[] of an object. Below is the code to convert object to byte[].
private byte[] getErrorData(FIFData fifData, boolean beforeException, String requestID) {
ErrorLog errorLog = new ErrorLog();
errorLog.setErrorDate(new Date());
errorLog.setErrorDescription(fifData);
errorLog.setErrorModule("Pre Reg");
if (beforeException){
errorLog.setErrorSummary("RequestID = " + requestID +" Before Exception");
}else{
errorLog.setErrorSummary("RequestID = " + requestID +" After Exception");
ByteArrayOutputStream baos = null;
ObjectOutputStream oos = null;
byte[] bytErrorLog = null;
try {
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(errorLog);
oos.flush();
bytErrorLog = baos.toByteArray();
} catch (IOException e) {
log(e);
} finally {
if (baos != null){
try {
baos.close();
} catch (IOException e1) {
log(e1);
return bytErrorLog;
}I have two questions. First is currently I have got the log file generated by above code. Is there any way to continue to read object from log file?
If can't, the second question is how to write object to file in such suitation (SessionBean) so that I can continue to read object in the future? -
Creating File objects from all files in a folder.
Hi, I'm not too brilliant of a programmer, so this may be an obvious one that I could find in the API.
My goal is to compare files for similarities and then give some output, that's not too important.
My question is: How do I create an array of File objects from a folder of *.txt files, without creating each individually? Is there a way to simply get all the files from the folder?
File I/O is still pretty new to me. If I didn't give a good enough explanation, please say so.
Thank you very much!Note by the way that a File represents an abstract pathname, the idea of a file as a location. It doesn't specify the file's contents, nor does it require that the file it represents actually exists. A better name might be "theoretical file" or "directory listing entry".
So getting a whole bunch of File objects is itself perhaps not necessary (although it could be useful).
To expand on reply #1, look for File methods whose names start with "list". -
How can i upload more than one single file into a folder in the creative cloud?
how can i upload e.g. 10 files out of a folder on my desktop in one step into a folder in my creative cloud?
You can select multiple files in the Windows Explorer dialog using the Ctrl key, or in Mac OS X Finder using the Cmd key. Once you have multiple files selected just click the upload button. Or use drag and drop from the desktop to the browser.
If you are using Internet Explorer it does not support multiple file upload. This is per design by Microsoft. -
How to do a FFT tranformation for every file in a folder of another folder?
Dear all,
I have a folder A, there are seven folders in folder A, I call these seven folders B. and there are 100 files in every folder B. These files are all the data information of current.
ok, now I need to transfer every current file into a FFT tranformation, and save the transferred files corresponding to the original file.
Does anyone have some idea? Thank you for any help!
JingHi Mike
In this way, How can I save the transferred files as the same way as the original files and folders?
after FFT transformation, I hope to get 100 files in every "transferred B" and seven "transferred B" folders in one "transferred A" folder.
Jing -
How to check whether there r new txt files in a folder n file creation date
How to check whether there r new text files in a specified folder and what is the date of creation of the text file.........?
Hi
I have been searching for a solution to find the date of creation of a file for over 6 months now but haven't found it. So I presume that it is not possible though I havent found any authentication of my assumption in any document.
Cheers!
Shailesh -
How to know the DB objects using the particular tablespace
Hi All
I have tablespace which is used by different database objects.
I want to know which objects are using that tablespace.
How can I know this??
ThanksI have tablespace which is used by different database objects.
I want to know which objects are using that tablespace.
How can I know this??
select owner,segment_name,segment_type,tablespace_name from dba_segments where tablespace_name='&TBS'; -
How to know that remote object connection with server has not disconnected?
Hi,
In my application want to check weather connnection with
remote object has disconnected or not. I have not found any
property with remoteobject to verify this. Weather it is possible
with remote object or if not then how it could be done with
channel. I have checked connected property of channel but i could
not find out how it works.
Is there any solution for this, if any one know please
reply...
Thanks..Did you ever get resolved. I am having the sames issues
Regards,
Wally
http://www.level10solutions.com -
How to know which universe object is used in which BO documents?
Post Author: rOmain
CA Forum: Administration
Hi,
what is the easy way to know, at any time, if an object on a specific universe is used in BO documents (Desk I).
BO support advises me to use Uuditor, but I want to know if users have another solution.
Thanks for your feedback,
Regards,
rOmainPost Author: V361
CA Forum: Integrated Solutions
What are you using CR XI ? or ???
Maybe you are looking for
-
Asset Purchase Via Purchase order
When i try to raise PO to purchase Asset by asisgning material group and account assignment the below error occured. G/L account 201000 cannot be used (please correct) Message no. ME045 Diagnosis Comparison of the field selection strings from the
-
Problems with special characters in JSP app
Hello! I am working for a JSP application which uses special characters. The database used is a Novell MySQL version, it is fine. I use Tomcat, Apache. I do not think that the versions are important. ON NT: The application works fine with special cha
-
Thinking of selling?......
I was thinking of selling my iBook, its about 8 months old and in brilliant condition. I've done some research and i think if i play my cards right i could get £450 - £550 on eBay its got everything that came with it (including the original box) and
-
SPA303 Provisioning over SSL with Client Verification problem
Hello, We use DHCP (66) HTTPS URL for provisioning and initial configuration of SPA303 phones. When Client Verification is enabled - the phones fail to authenticate to the web server and provisioning fails. It works perfectly when Client Verification
-
Mp3 player compatible with mac
I was looking for a non ipod that is compatible with the mac 10.4 os. i want the fm radio option and disposible battery option . i want to be able to use itunes to transfer songs. any recommended models thanks