Get directory of a file
hi, am programing with java applet, and there's a method getDocumentBase() which returns the full URL. however i just need the directory where the file resides, not the file name. i.e., i want
d:/this/is/the/dir/
instead of
d:/this/is/the/dir/applet.htm
where .htm contains the applet.
any hints pls? thx alot!
sory,
the prob is i want to store some images in another folder rather than the same dir as the html. so for example, the html goes
d:/this/is/html/
then i want images in
d:/this/is/html/images
and now an applet embedded in the html file needs to read those images, so am wondering how to get the url of the html dir, then attach /images to the end of that so as to get the url of all image files.
there is a method getImage(URL, String) which seems to fulfil this need however, that only works if all image files reside in the same dir of the html file.
hope that makes it clear. thx
Similar Messages
-
Get directory listing or files contained in a folder which is placed on a s
Hello,
I want to get the directory listing of a particular folder say 'xyz' which is placed on the server.
I am using tomcat. I want to use Http to do it. How do it do it.
Please guide.
Regards,
JAVA_studentJAVA_student ,
as pointed out file list is (in productional environments) usually turned off for security reasons.
But I had a similiar requirement to the one you posted. I had a directory with thousands of image files with the name pattern <id>.jpg and the id's stored in a database. Not for every id in the database there existed a file. I wanted to show an image or in case the image file did not exist a default jpg. I could not set the error pages in web.xml to do it.
So I had to take the id (a parameter in the request to the servlet I wrote for that), had to concat it with the 'virtual' directory name used in the applicationserver for the img directory. Then I had to check the existance of the file and to load it it and display it, if it existed otherwise I had to load and display the default picture.
The problem is similiar to yours as the problem basically is to map a directory in a web application to a real directory in a filesystem (which works for files and directories.
The answer is use getRealPath(String) of the ServletContext-object.
Note: This only allows access to files and directories in the web application.
e.g.
http://www.theserver.com/mywebapp/img/ is a folder containing img files. The server does not allow directory listing.
In a jsp within the application mywebapp you want to show a list of the files in /mywebapp/img/ .
<HTML>
<BODY>
<%
// in a jsp application gives you access to the context
String sRealPath = application.getRealPath("/img") ;
java.io.File fDir = new java.io.File(sRealPath) ;
java.io.File[] allFiles = fDir.listFiles() ;
for (int i = 0 ; i < allFiles.length;i++) {
String sName = allFiles.getName() ;
%>
<%=sName%><br>
<%
%>
</BODY>
</HTML> -
Get directory of excel file in VBA Access
Background: Access database is established. A procedure is written in Access VBA. When I run the procedure it selects the path of 'excel file' and opens it, slpits the data into different tables. To improvise, a form is created with import
button on it. when I click on it, the procedure is executed.
Problem: How do I do the following steps by clicking on the import button in Access VBA: click_import_button >> Choose the excel file dailog box opens >> select the excel file >> Execute the procedure.
Following is my code(some part of it is deleted), with the path mentioned;
Public Sub trial()
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim vPartDes As String, vPartWeight As Double
Dim vPartLength As Double, vPartWidth As Double
Dim vPartHeight As Double, vBZA As String
Dim vSAAname As String, vSAAnumber As String, vBMName As String, vBMnumber As String
Dim blnEXCEL As Boolean
Dim uid As Integer
Dim rsUID As DAO.Recordset
Dim vSNR As String, vNewSNR As String, VUID As String
Dim rs, rsNewSnr, qs, js, ks, hs As DAO.Recordset
'Dim wrkCurrent As DAO.Workspace
Dim mydb As DAO.Database
blnEXCEL = False
'Establish an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlx = CreateObject("Excel.Application")
blnEXCEL = True
End If
Err.Clear
On Error GoTo 0
'Change True to False if you do not want the workbook to be visible when the code is running
xlx.Visible = False
Set xlw = xlx.Workbooks.Open("C:\Users\YSRINID\Desktop\Book1.xls", True) 'opens in read-only mode
'Actual name of the worksheet
Set xls = xlw.Worksheets("Sheet1")
Set xlc = xls.Range("F2") ' This is the first cell (reference) that contains data (non-header information)
Set mydb = CurrentDb()
'Set wrkCurrent = DBEngine.Workspaces(0)
'wrkCurrent.BeginTrans
' write data to the recordset
Do While Not IsEmpty(xlc.Value)
vBMnumber = xlc.Offset(0, -4)
vBMName = xlc.Offset(0, -3)
vSAAnumber = xlc.Offset(0, -2)
vSAAname = xlc.Offset(0, -1)
vSNR = xlc.Value
vNewSNR = xlc.Offset(0, 1).Value
vPartDes = xlc.Offset(0, 2).Value
vPartWeight = xlc.Offset(0, 3).Value
vPartLength = xlc.Offset(0, 4).Value
vPartWidth = xlc.Offset(0, 5).Value
vPartHeight = xlc.Offset(0, 6).Value
vBZA = xlc.Offset(0, 7).Value
Dim tsql, usql, vsql, wsql, xsql As String
'Search BMnumber and SAAnumber combination in Variant_SAA
wsql = " SELECT * FROM Variant_SAA where BMnumber like '" & vBMnumber & "' and SAAnumber like '" & vSAAnumber & "'"
Set ks = mydb.OpenRecordset(wsql)
If ks.EOF Then
mydb.Execute "INSERT INTO Variant_SAA(BMnumber,SAAnumber) values('" & vBMnumber & "', '" & vSAAnumber & "') "
'Search for SNR or NewSNR
tsql = "SELECT * FROM SNR_Log where SNR like '" & vSNR & "' or SNR like '" & vNewSNR & "'"
Set rs = mydb.OpenRecordset(tsql)
If rs.RecordCount > 0 Then
rs.MoveFirst
VUID = rs!uid
Else
VUID = -1
End If
If VUID > 0 Then
' Update information in Part_Source table
mydb.Execute "UPDATE [Part_Source] SET PartDes = '" & vPartDes & "', PartWeight = '" & vPartWeight & "' , PartLength ='" & vPartLength & _
"' , PartWidth= '" & vPartWidth & "', PartHeight= '" & vPartHeight & "' , BZA = '" & vBZA & "' WHERE UID like '" & VUID & "'"
Else
' Insert part data into Part_Source table
mydb.Execute "INSERT INTO Part_Source(PartDes, PartWeight, PartLength , PartWidth , PartHeight , BZA) values ('" & vPartDes & "', '" & _
vPartWeight & "', '" & vPartLength & "', '" & vPartWidth & "', '" & vPartHeight & "', '" & vBZA & "')"
' Read UID of last record
Set rsUID = mydb.OpenRecordset("select @@identity")
Debug.Print rsUID(0)
VUID = rsUID(0)
' take UID and insert into SNR_log with SNR
mydb.Execute "INSERT INTO SNR_log (UID, SNR) values ('" & VUID & "','" & vSNR & "')"
End If
'Search for SAA and UID combination in SAA_Part
xsql = " SELECT * FROM SAA_Part where SAAnumber like '" & vSAAnumber & "' and UID like '" & VUID & "' "
Set hs = mydb.OpenRecordset(xsql)
If hs.EOF Then
mydb.Execute "INSERT INTO SAA_Part(SAAnumber,UID) values ('" & vSAAnumber & "', '" & VUID & "')"
Else
Set xlc = xlc.Offset(1, 0)
End If
Loop
'If MsgBox("Save all changes?", vbQuestion + vbYesNo) = vbYes Then
'wrkCurrent.CommitTrans
'Else
'wrkCurrent.Rollback
'End If
'Set wrkCurrent = Nothing
'Close Recordsets
rs.Close
Set rs = Nothing
rsNewSnr.Close
Set rsNewSnr = Nothing
qs.Close
Set qs = Nothing
js.Close
Set js = Nothing
ks.Close
Set ks = Nothing
hs.Close
Set hs = Nothing
'Close Database
mydb.Close
Set mydb = Nothing
' Close the EXCEL file without saving the file, and clean up the EXCEL objects
Set xlc = Nothing
Set xls = Nothing
xlw.Close False
Set xlw = Nothing
Set xlx = Nothing
Exit Sub
If blnEXCEL = True Then xlx.Quit
End Sub
Thanks in advance!You can't just call your procedure since it opens a fixed workbook. (Moreover, it is missing an End If).
Here is the On Click event procedure for a command button cmdImport:
Private Sub cmdImport_Click()
Dim strFile As String
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim vPartDes As String, vPartWeight As Double
Dim vPartLength As Double, vPartWidth As Double
Dim vPartHeight As Double, vBZA As String
Dim vSAAname As String, vSAAnumber As String, vBMName As String, vBMnumber As String
Dim blnEXCEL As Boolean
Dim uid As Integer
Dim rsUID As DAO.Recordset
Dim vSNR As String, vNewSNR As String, VUID As String
Dim rs, rsNewSnr, qs, js, ks, hs As DAO.Recordset
'Dim wrkCurrent As DAO.Workspace
Dim mydb As DAO.Database
With Application.FileDialog(1) ' msoFileDialogOpen
.Filters.Clear
.Filters.Add "Excel workbooks (*.xls*)", "*.xls*"
If .Show Then
strFile = .SelectedItems(1)
Else
MsgBox "No workbook specified!", vbExclamation
Exit Sub
End If
End With
blnEXCEL = False
'Establish an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlx = CreateObject("Excel.Application")
blnEXCEL = True
End If
Err.Clear
On Error GoTo 0
'Change True to False if you do not want the workbook to be visible when the code is running
xlx.Visible = False
Set xlw = xlx.Workbooks.Open(strFile, True) 'opens in read-only mode
'Actual name of the worksheet
Set xls = xlw.Worksheets("Sheet1")
Set xlc = xls.Range("F2") ' This is the first cell (reference) that contains data (non-header information)
Set mydb = CurrentDb
'Set wrkCurrent = DBEngine.Workspaces(0)
'wrkCurrent.BeginTrans
' write data to the recordset
Do While Not IsEmpty(xlc.Value)
vBMnumber = xlc.Offset(0, -4)
vBMName = xlc.Offset(0, -3)
vSAAnumber = xlc.Offset(0, -2)
vSAAname = xlc.Offset(0, -1)
vSNR = xlc.Value
vNewSNR = xlc.Offset(0, 1).Value
vPartDes = xlc.Offset(0, 2).Value
vPartWeight = xlc.Offset(0, 3).Value
vPartLength = xlc.Offset(0, 4).Value
vPartWidth = xlc.Offset(0, 5).Value
vPartHeight = xlc.Offset(0, 6).Value
vBZA = xlc.Offset(0, 7).Value
Dim tsql, usql, vsql, wsql, xsql As String
'Search BMnumber and SAAnumber combination in Variant_SAA
wsql = " SELECT * FROM Variant_SAA where BMnumber like '" & vBMnumber & "' and SAAnumber like '" & vSAAnumber & "'"
Set ks = mydb.OpenRecordset(wsql)
If ks.EOF Then
mydb.Execute "INSERT INTO Variant_SAA(BMnumber,SAAnumber) values('" & vBMnumber & "', '" & vSAAnumber & "') "
'Search for SNR or NewSNR
tsql = "SELECT * FROM SNR_Log where SNR like '" & vSNR & "' or SNR like '" & vNewSNR & "'"
Set rs = mydb.OpenRecordset(tsql)
If rs.RecordCount > 0 Then
rs.MoveFirst
VUID = rs!uid
Else
VUID = -1
End If
If VUID > 0 Then
' Update information in Part_Source table
mydb.Execute "UPDATE [Part_Source] SET PartDes = '" & vPartDes & "', PartWeight = '" & vPartWeight & "' , PartLength ='"
& vPartLength & _
"' , PartWidth= '" & vPartWidth & "', PartHeight= '" & vPartHeight
& "' , BZA = '" & vBZA & "' WHERE UID like '" & VUID & "'"
Else
' Insert part data into Part_Source table
mydb.Execute "INSERT INTO Part_Source(PartDes, PartWeight, PartLength , PartWidth , PartHeight , BZA) values ('" & vPartDes & "', '" &
vPartWeight & "', '" & vPartLength & "', '" & vPartWidth
& "', '" & vPartHeight & "', '" & vBZA & "')"
' Read UID of last record
Set rsUID = mydb.OpenRecordset("select @@identity")
Debug.Print rsUID(0)
VUID = rsUID(0)
' take UID and insert into SNR_log with SNR
mydb.Execute "INSERT INTO SNR_log (UID, SNR) values ('" & VUID & "','" & vSNR & "')"
End If
End If
'Search for SAA and UID combination in SAA_Part
xsql = " SELECT * FROM SAA_Part where SAAnumber like '" & vSAAnumber & "' and UID like '" & VUID & "' "
Set hs = mydb.OpenRecordset(xsql)
If hs.EOF Then
mydb.Execute "INSERT INTO SAA_Part(SAAnumber,UID) values ('" & vSAAnumber & "', '" & VUID & "')"
Else
Set xlc = xlc.Offset(1, 0)
End If
Loop
'If MsgBox("Save all changes?", vbQuestion + vbYesNo) = vbYes Then
'wrkCurrent.CommitTrans
'Else
'wrkCurrent.Rollback
'End If
'Set wrkCurrent = Nothing
'Close Recordsets
rs.Close
Set rs = Nothing
rsNewSnr.Close
Set rsNewSnr = Nothing
qs.Close
Set qs = Nothing
js.Close
Set js = Nothing
ks.Close
Set ks = Nothing
hs.Close
Set hs = Nothing
'Close Database
mydb.Close
Set mydb = Nothing
' Close the EXCEL file without saving the file, and clean up the EXCEL objects
Set xlc = Nothing
Set xls = Nothing
xlw.Close False
Set xlw = Nothing
Set xlx = Nothing
If blnEXCEL = True Then xlx.Quit
End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
How to get the current executing file/itself absolute directory?
hellooo,
gentlemen/lady, how to get the current executing file/itself absolute directory?
thanks
Hello,
you can get the real path information of the JSP through the servlet context:
http://java.sun.com/products/servlet/2.2/javadoc/index.html
javax.servlet
Interface ServletContext
Method getRealPath
Christian Plenagl
Developer Relations Engineer
BEA Support
[email protected] (alex mok) wrote:
>hellooo,
>
>gentlemen/lady, how to get the current executing file/itself absolute
>directory?
>
>thanks
-
How can I get Directory and Files from a Maped Networkdrive of the AppS
Hello,
we have the following Situation.
We have a Windows-Server (Server-A) in an Network with ActivDirectory and an Windows-Server (Server-B with an WebApplicationServer outside of these ActivDirectory as standalone.
On Server-B we mapped a Directory from Server-A (FileExplorer and then MapNetworkDrives) as Drive Q.
Now i tried to get the Directory of Q:\abcd but it doesn't work.
I tried the FM EPS_GET_DIRECTORY_LISTING and also RZL_READ_DIR, but both doesn't worked.
RZL_READ_DIR is doing a "CALL 'ALERTS' ..." and is comming back with sy-subrc = 1
EPS_GET_DIRECTORY_LISTING is doing a "CALL 'C_DIR_READ_FINISH'..." and comes back with "Wrong order of calls" in the Field file-errmsg. Next Call is "CALL 'C_DIR_READ_START'..." and this comes back with "opendir" in Field file-errmsg.
I tried the same with two Servers in the same ActivDirectory-Network. The Result was the same, i don't get the directory of the mapped drive. But now i get from the Call "CALL 'C_DIR_READ_START'..." the file-errmsg "opendir: Not a directory" and file-errno 20.
Is there any idea for solving my Problem?
I have to get this directory, read the files from the List and have to rename them after wriing the data to our databasefile.
I want to read them with OPEN DATASET, rename them by writing a new File (also OPEN DATASET) and after that i do an DELETE DATASET.
Thanks and Greetings Matthias
Edited by: Matthias Horstmann on Mar 25, 2009 4:12 PM
Filled in Scenario with 2 Servers in same AD-NetworkHalo Mattias,
i using this function get file file name and directory:
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
importing
file_name = p_file.
Rgds,
Wilibrodus -
How to get the path when i select a directory or a file in a JTree
How to get the path when i select a directory or a file in a JTree
import java.lang.*;
import java.io.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.HeadlessException;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Iterator;
* @author Frederic FOURGEOT
* @version 1.0
public class JTreeFolder extends JPanel {
protected DefaultMutableTreeNode racine;
JTree tree;
protected JScrollPane scrollpane;
final static int MAX_LEVEL = 1; // niveau max de descente "direct" dans l'arborescence
* Sous-classe FSNode
* @author Frederic FOURGEOT
* @version 1.0
private class FSNode extends DefaultMutableTreeNode {
File file; // contient le fichier li� au noeud
* Constructeur non visible
private FSNode() {
super();
* Constructeur par initialisation
* @param userObject Object
FSNode(Object userObject) {
super(userObject);
* Constructeur par initialisation
* @param userObject Object
* @param newFile File
FSNode(Object userObject, File newFile) {
super(userObject);
file = newFile;
* Definit le fichier lie au noeud
* @param newFile File
public void setFile(File newFile) {
file = newFile;
* Renvoi le fichier lie au noeud
* @return File
public File getFile() {
return file;
public JTree getJTree(){
return tree ;
* Constructeur
* @throws HeadlessException
public JTreeFolder() throws HeadlessException {
File[] drive;
tree = new JTree();
// cr�ation du noeud sup�rieur
racine = new DefaultMutableTreeNode("Poste de travail");
// cr�ation d'un noeud pour chaque lecteur
drive = File.listRoots();
for (int i = 0 ; i < drive.length ; i++) {
FSNode node = new FSNode(drive, drive[i]);
addFolder(drive[i], node); // on descend dans l'arborescence du lecteur jusqu'� MAX_LEVEL
racine.add(node);
// Gestion d'evenement sur JTree (on �coute les evenements TreeExpansion)
tree.addTreeExpansionListener(new TreeExpansionListener() {
public void treeExpanded(TreeExpansionEvent e) {
// lorsqu'un noeud est ouvert
// on descend dans l'arborescence du noeud jusqu'� MAX_LEVEL
TreePath path = e.getPath();
FSNode node = (FSNode)path.getLastPathComponent();
addFolder(node);
((DefaultTreeModel)tree.getModel()).reload(node); // on recharche uniquement le noeud
public void treeCollapsed(TreeExpansionEvent e) {
// lorsqu'un noeud est referm�
//RIEN
// alimentation du JTree
DefaultTreeModel model = new DefaultTreeModel(racine);
tree.setModel(model);
setLayout(null);
// ajout du JTree au formulaire
tree.setBounds(0, 0, 240, 290);
scrollpane = new JScrollPane(tree);
add(scrollpane);
scrollpane.setBounds(0, 0, 240, 290);
* Recuperation des sous-elements d'un repertoire
* @param driveOrDir
* @param node
public void addFolder(File driveOrDir, DefaultMutableTreeNode node) {
setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
addFolder(driveOrDir, node, 0);
setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
* Recuperation des sous-elements d'un repertoire
* (avec niveau pour r�cursivit� et arr�t sur MAX_LEVEL)
* @param driveOrDir File
* @param node DefaultMutableTreeNode
* @param level int
private void addFolder(File driveOrDir, DefaultMutableTreeNode node, int level) {
File[] fileList;
fileList = driveOrDir.listFiles();
if (fileList != null) {
sortFiles(fileList); // on tri les elements
// on ne cherche pas plus loin que le niveau maximal d�finit
if (level > MAX_LEVEL - 1) {return;}
// pour chaque �l�ment
try {
for (int i = 0; i < fileList.length; i++) {
// en fonction du type d'�l�ment
if (fileList[i].isDirectory()) {
// si c'est un r�pertoire on cr�� un nouveau noeud
FSNode dir = new FSNode(fileList[i].getName(), fileList[i]);
node.add(dir);
// on recherche les �l�ments (r�cursivit�)
addFolder(fileList[i], dir, ++level);
if (fileList[i].isFile()) {
// si c'est un fichier on ajoute l'�l�ment au noeud
node.add(new FSNode(fileList[i].getName(), fileList[i]));
catch (NullPointerException e) {
// rien
* Recuperation des sous-elements d'un noeud
* @param node
public void addFolder(FSNode node) {
setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
for (int i = 0 ; i < node.getChildCount() ; i++) {
addFolder(((FSNode)node.getChildAt(i)).getFile(), (FSNode)node.getChildAt(i));
setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
* Tri une liste de fichier
* @param listFile
public void sortFiles(File[] listFile) {
triRapide(listFile, 0, listFile.length - 1);
* QuickSort : Partition
* @param listFile
* @param deb
* @param fin
* @return
private int partition(File[] listFile, int deb, int fin) {
int compt = deb;
File pivot = listFile[deb];
int i = deb - 1;
int j = fin + 1;
while (true) {
do {
j--;
} while (listFile[j].getName().compareToIgnoreCase(pivot.getName()) > 0);
do {
i++;
} while (listFile[i].getName().compareToIgnoreCase(pivot.getName()) < 0);
if (i < j) {
echanger(listFile, i, j);
} else {
return j;
* Tri rapide : quick sort
* @param listFile
* @param deb
* @param fin
private void triRapide(File[] listFile, int deb, int fin) {
if (deb < fin) {
int positionPivot = partition(listFile, deb, fin);
triRapide(listFile, deb, positionPivot);
triRapide(listFile, positionPivot + 1, fin);
* QuickSort : echanger
* @param listFile
* @param posa
* @param posb
private void echanger(File[] listFile, int posa, int posb) {
File tmpFile = listFile[posa];
listFile[posa] = listFile[posb];
listFile[posb] = tmpFile; -
Problem with getting a list of files in a directory
I'm trying to get a list of files in a particular directory. The problem is I'm also getting a listing of all the sub-directories too. Here is my code:
File directory = new File(dir);
File[] filelist;
filelist = directory.listFiles();
for(int i=0;i<filelist.length;i++)
System.out.println("FileName = " + filelist.getName());
What am I doing wrong?
Thanks
BradYou are not doing anything wrong. You just have to test whether a given file is a subdirectory:
File directory = new File(dir);
File[] filelist;
filelist = directory.listFiles();
for(int n = 0; n < filelist.length; n++) {
if (!filelist[n].isDirectory())
System.out.println("FileName = " + filelist[n].getName());
}Søren Bak -
Getting a list of files from a shared directory
Hi All,
I need to get a list of files from a shared directory on another server and put them in a HTMLB TableView element with links to the files.
I was not successful with CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES. This method works in test mode, but gives me a gui_not_supported exception in BSP. I guess BSPs are not allowed to use this.
Is there any other alternative?
I need to be able to upload the files as well.
Thanks,
Roman
Message was edited by: Roman DubovHi again,
Not sure about the shared directory files list...
In my opinion, this cannot be done using BSP.
But, you can try using VBScript to access the file system with object of that sort :
CreateObject("Scripting.FileSystemObject")
it is only a thought and you can be sure to cross security problems by accessing files through a Web application...
Best regards,
Guillaume -
Getting the list of files in a directory by their last modified date
Dear friends,
I want to get the list of files in a directory sorted by their last modified date.
By default the file.list() or listFiles() return files sorted by their name in ascending order.
Please give me your suggestions.
Thanks in advance,
James.Thanks friend,
I myself got the answer
here is my code:
public File[] getSortedFileList(File dir){
File[] originalList = dir.listFiles();
int numberOfFiles = originalList.length;
File[] sortedList = new File[numberOfFiles];
long[] lastModified = new long[numberOfFiles];
for(int i = 0; i < numberOfFiles; i++){
lastModified[i] = originalList.lastModified();
Arrays.sort(lastModified);
for(int i = 0; i < numberOfFiles; i++){
for(int k = 0; k < numberOfFiles; k++){
if(originalList[k].lastModified() == lastModified[i])
sortedList[i] = originalList[k];
System.out.println("The sorted file list is:" + sortedList[i]);
return sortedList; -
Trying to download ITunes latest version on my Windows XP and I get this message: "The installer has insufficient privileges to access this directory: C:\Program Files\ITunes. The installation cannot continue. Log on as administrator or contact your system administrator." HELP?
Hello PamelaFox14,
Thank you for using Apple Support Communities.
It sounds like you need to log in as the administrator to update the iTunes application properly.
Take a look at this article named:
Trouble installing iTunes or QuickTime for Windows
http://support.apple.com/kb/HT1926
This section in particular:
1. Make sure you have administrator account access
To install iTunes or QuickTime software, you need to be logged in as an administrator on the computer. If you're not sure if you have administrator account access, you may find this Microsoft article helpful:
Windows 7: How do I log on as an administrator?
Otherwise, refer to the Help documentation from Microsoft, contact your IT department, or visitsupport.microsoft.com for more information.
All the best,
Sterling -
I keep getting the "No such file or directory" error when files really
I keep getting the "No such file or directory" error when files really
i did some research online and found nothing yet, can anyone help, this has been happening with new files for like a week. thanksadditional information needed.
solely stating "i hav problemz plz halp" never leads to a solution
read this:
http://www.catb.org/~esr/faqs/smart-questions.html
Last edited by robmaloy (2009-04-21 07:16:16) -
FTP: how to get total number of files in directory
Hello Folks,
I prefer to use FTP from the command line but cannot figure out how--after having connected to a remote directory via ftp--to list the total number of files in that directory.
In Unix, I would do this:
% ls | wc -l
But hopefully there is also some way in FTP to do the same--but darned if I know how! I do see that FTP clients such as Transmit have this listing, but maybe that's a feature of the software and not ftp.
Thanks in advance for any suggestions/tips.
DougI've done a lot of ftp scripts 10 years ago, mostly because I could not guarantee my scripted telnet would be available everywhere. The best answer today though is listed throughout this thread and that is to use the ssh family of commands that include ssh for secure remote shell, scp for secure remote copy and sftp which is the ftp interface to scp.
My point is neither telnet or ftp are considered safe or secure anymore because listening to communications is popular, it is referenced in most "wizard" magazines, and usernames and passwords are not encrypted.
Set up your environment first with ssh-keygen. Version 2 is more secure than version 1 if both are still offered. Then use "ssh user@hostname ls | wc -l" to get your number of files. It is simple execution with one command and returns a status.
If you are really looking for a solution using what you are familar with and want to ignore advice concerning security, here is a sample batch script (untested). You can change the filenames, usernames, and hostnames as desired.
rm dir.out 2> /dev/null
echo "user sampleuser samplepw" > script.ftp
echo "dir sampledirectory dir.out" >> script.ftp
echo "quit" >> script.ftp
ftp -n sample.hostname < script.ftp
if [ ! -r dir.out ] # file not created
then
echo login failed
elif [ ! -s dir.out ] # file created but empty
then
echo directory is empty
else
nf=`wc -l dir.out | cut -f1`
echo "There are $nf files in the directory"
fi -
Getting names of all files in a directory.
import java.io.*;
import java.util.*;
public class dir{
public static void main(String args[]) throws IOException{
//BufferedReader in = new BufferedReader(new FileReader(args[0]));
PrintWriter out = new PrintWriter(new FileWriter("dir.txt"));
File file = new File(args[0]);
//FileFilter filefilter = "log";
Vector x = new Vector();
int vlength;
x = getDirectoryContent(file);//,filefilter);
vlength = x.size();
for(int i=0;i<x.size();i++){
out.println(x.elementAt(i));
out.close();
public static Vector getDirectoryContent(File file){//, FileFilter fileFilter){
Vector v= new Vector();
if (file.isDirectory()) {
File[] content = file.listFiles();//fileFilter);
for (int i=0; i<content.length; i++){
v.addElement(content);
}//for
}//is directory
return v;
}//getDirectoryContent
That is the code that I am using, what I am trying to do with it is read all the files in a directory. So I can open them and calculate all the data in all of the files at the same time.
These are the file names that are in the directory when I run the program.
L0519013.log
L0331001.log
I have the code out put the file names in a file called dir.txt
after running the program this is what I get in the output file.
[Ljava.io.File;@70ccc4b2
[Ljava.io.File;@70ccc4b2
[Ljava.io.File;@70ccc4b2
Any clue waht this means?
also I am passing in the director as args[0]if possible as well...
I could not get the FileFilter to work, could not get the syntax down to get it to work when I was initializing it so for the moment it is remed out. all files in the given directory will be of type .log so there really is no need for the FileFilter. But any help on how to include that in the code would be greatly helpful.
Thankxs
Korbin -
How to get and read a file from META-INF directory
how to get and read a file from META-INF directory in a EJB project
Use this.getClass().getResourceAsStream("/META-INF/filename");This should work. Probably, you would need to set the Manifest Class-Path attribute.
-
Get the directory where application files exist.....
Hi ,
How to get the directory where application files exist....????
I have found a way....such as:
Right - click on the application name ... on the pop-up menu... select "Add to <application_name>" and then on the window appeared... i get the dir on the title of this window....
Is there any simpler method to obtain the dir...????
NOTE: I use JDev 10.1.3. on windows XP platform...
Many thanks ,
Simonhi Simon
If you not only want to see the path, but also want to copy-and-paste it, you can use the "Edit > Copy Path" (Ctrl+Shift-C) menu item.
success
Jan Vervecken
Maybe you are looking for
-
Can't open 32 bit in 10.5
i don't know how to put my itunes in the 32 bit mode.
-
Hi, just a short question. Can I use my fire-wire power supply and the appropriate cable from my 4th gen. classic ipod (monochrome display) to charge the battery of my ipod nano 3rd gen.? Or do I have to use a new USB power supply? Thank you! Mike
-
Spy not working correctly?
I recently had to reinstall CS3 onto my computer. I installed all the updates available. I have had my site up for over a year with no problems at all. Now that I reinstalled all hell has broke loose. For example when I upload a web page, the cont
-
Parameterized cursor for varient Table name?
Hi all, I am using Oracle 9i and have a cursor defined as :- Code: CREATE PROCEDURE Proc_Abc AS CURSOR My_Cursor (UserName VARCHAR) IS SELECT Emp_Name, Salary FROM Employee_Table WHERE User_Name = UserName; (Rest of the code) This code is workin
-
I think you should be able to choose apps to go on our lock screen for quick acsess
This would be extremely helpful for me because it takes me a little bit to unlock my ipod and it seems like you can only do this jail broken such I don't want