String file names?
How do i change the name of the file from my directory using java code?
i want the code to change the name of my files to 1, 2, 3, and so on...
Thankyou
Hemant
The Java™ Tutorial - A practical guide for programmers
Essentials, Part 1, Lesson 1: Compiling & Running a Simple Program
New to Java Center
How To Think Like A Computer Scientist
Introduction to Computer Science using Java
The Java Developers Almanac 1.4
JavaRanch: a friendly place for Java greenhorns
jGuru
Bruce Eckel's Thinking in Java
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java
Similar Messages
-
Selection of Localizable.strings and .strings file naming?
Hi Apple Developer Folks,
In the process of embedding Internalization for strings in my project, I referred to the "InternationalMountains" sample code project.
In that project there are three languages supported, English, French and Chinese.
What I do not understand is why all three Localizable.strings files have been checked in Localization section of the File Inspector.
This is the case for the other two such files, as well.
(See the full sized image at http://www.drake.org/images/AllThreeBoxes.jpg )
Also, I have one other question: "What is the suggested mechanism for controlling the NAMING of the Localizable.strings files?"
If I wanted to name the files something like "StandardApp.strings" or "ProApp.strings" - where and how would that be accomplished?
As it is, if the files are not named "Localizable.strings" - the NSLocalizedString(key, comment); calls do not work as intended.
Thanks very much!I'm guessing that most use the default naming of the localization strings files, which are packaged with related localized files in the appropriate resource folder - your screenshot is just showing that there are three localizations for that name.
You can use any name you want when creating a strings file - Foundation's NSLocalizedString just uses the default Localizable.string file name by calling NSBundle's localizedStringForKey:value:table: method with a nil value for the table. You can use other names by calling that method or by using Foundation's NSLocalizedStringFromTable, passing the desired table name (the file to use). -
Extracting string from a file name
Hello,
I have a legacy (read: I didn't build it) SharePoint list that includes some validation when uploading files that's giving me some trouble.
Basically, our users are required to add files to a list in a certain filename format and based on the naming convention are approved/rejected and routed to the appropriate location.
One of the validations looks at a section of the file name and compares it to a folder name in the library.
For example, the file name format is XX_AAA_999_2014_05.xlsx and that matches on the folder name of /submissions/2014_05
Currently the rule says look at the last 7 characters of the folder and the 7 characters starting at position 12 of the filename and make sure they match.
The problem is the 999 in the example above is a sequential identifier to the project a file is associated with... e.g. they range from project 000 to project 999. We've now hit project 1000 so file being added for project 1000 (and beyond) fails because
the starting position has shifted one spot. (Note: we have active 3 digit projects so I cannot simply change that to be position 13... not to mention what that does to my history).
So, my task is to come up with something that can accomodate 3 or 4 digit numbers.
I'm trying to stick as closely to the original setup so I don't mess up the history so I'm looking at other methods of getting to the same data in the string. Another problem is that the file names include the extension and the extension can be 3 (pdf)
or 4 (xlsx) characters long.
I've tried this: =LEFT([Source File Name],SEARCH(".",[Source File Name])-1)
but that brings back everything in front of the period and I need just the 7 preceeding characters. Is there a way to limit the number of chars a LEFT() function returns?
In a nutshell, the 4 variations of file names are as follows of which I need to extract the
bolded section.:
ZZ_AAA_999_2014_05.xls
ZZ_AAA_999_2014_05.xlsx
ZZ_AAA_1000_2014_05.xls
ZZ_AAA_1000_2014_05.xlsx
Thanks!
KevinHi,
According to your description, you might want to retrieve the string “2014_05” from the file name.
I would suggest you create a SharePoint Designer workflow and implement your logic of handling the filename.
In SharePoint Designer 2010, there are already some useful utility workflow actions which can enable users to deal with the various requirements come from the business scenarios.
For the string handling, you can consider to use the
Utility Actions:
http://msdn.microsoft.com/en-us/library/office/jj164026(v=office.15).aspx
Another two links about creating SharePoint Designer workflow for your reference:
http://office.microsoft.com/en-001/sharepoint-designer-help/introduction-to-designing-and-customizing-workflows-HA101859249.aspx
http://www.codeproject.com/Tips/415107/Create-a-Workflow-using-SharePoint-Designer
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Patrick Liang
TechNet Community Support -
hello to all,
i have to save a file with a string..,with results of a test
the file name must include time and date of my test, and has to append 2 underscore if my test failed
some idea?
Using LabVIEW 7.1gigi85 wrote:
for months i need abbreviation of name JAN, FEB and so on
It is all right there in the online help: time format strings.
In this case use <%b> and optionally convert it to upper case.
LabVIEW Champion . Do more with less code and in less time . -
How to get IDL file name from CORBA IOR string
hi, is it possible to get IDL file name from the IOR string? how?
regardsHi,
I don't think so.
And if it was possible, which interface should be returned if
the referenced object implements more than one?
Regards.
Karl -
How to set file name in a JFileChooser to be some default String?
Dear all,
I am tring to make my JFileChooser more user-friendly, so every time that a JFileChooser show up, I would like to fill the file name with some default String, instead of just leaving them blank.
Does anybody know how to do this?
Many Thanks!look up the set...() methods of the JFileChooser api docs
-
Sorting string like windows file name sorting
Hi everybody, I have a simple question.
I was trying to sort some file name in java
Let say we have a list of string which are :
1.txt
a.txt
2.txt
11.txt
a(1).txt
a(11).txt
a(2).txt
If i convert those strings as file names, and sort it by file name in the windows explorer the result is
1.txt
2.txt
11.txt
a(1).txt
a(2).txt
a(11).txt
a.txt
But if i enter those strings into an Arraylist and use Arrays.sort or Collections.sort, the result is
1.txt
11.txt
2.txt
a(1).txt
a(11).txt
a(2).txt
a.txt
Is there a way to achieve the string sort similar to windows rather than aplhabetically like the default sort of Arrays/Collection.
I have done some searching but only found problem regarding to different language character sorting which can be achieved using Collator but this was not my case. Has anybody encounter this issue ?
Any help is greatly appreciated
regards
Hendra Effendiballistic_realm wrote:
Let say we have a list of string which are :
1.txt
a.txt
2.txt
11.txt
a(1).txt
a(11).txt
a(2).txt
If i convert those strings as file names, and sort it by file name in the windows explorer the result is
1.txt
2.txt
11.txt
a(1).txt
a(2).txt
a(11).txt
a.txt
...Not sure, but wouldn't Windows sort it like:
1.txt
2.txt
11.txt
a.txt
a(1).txt
a(2).txt
a(11).txt
If so, the try something like this (UNTESTED!):
class WindowsFileNamesComparator implements Comparator<String> {
public int compare(String a, String b) {
String[] tokensA = tokenize(withoutExtension(a));
String[] tokensB = tokenize(withoutExtension(b));
int max = Math.min(tokensA.length, tokensB.length);
for(int i = 0; i < max; i++) {
if(tokensA.equalsIgnoreCase(tokensB[i]))
continue;
else if(tokensA[i].matches("\\d+") && tokensB[i].matches("\\D+"))
return -1;
else if(tokensA[i].matches("\\D+") && tokensB[i].matches("\\d+"))
return 1;
else if(tokensA[i].matches("\\d+") && tokensB[i].matches("\\d+"))
return Integer.valueOf(tokensA[i])-Integer.valueOf(tokensB[i]);
else
return tokensA[i].compareTo(tokensB[i]);
return tokensA.length - tokensB.length;
private String[] tokenize(String s) {
List<String> tokens = new ArrayList<String>();
Matcher m = Pattern.compile("\\d+|\\D+").matcher(s);
while(m.find()) {
tokens.add(m.group());
return tokens.toArray(new String[]{});
private String withoutExtension(String s) {
int lastDot = s.lastIndexOf('.');
return lastDot < 0 ? s : s.substring(0, lastDot); -
Query string read as part of file name, throwing not found errors
Hi all, I host a number of Web sites under a CF7 installation, Win2003.
One site in particular is throwing not-found errors in response to certain search bot requests.
In the IIS log, I noticed that for these requests, the query part of the URL is part of cs-uri-stem field value, but is not in the cs-uri-query field where it belongs:
cs-uri-stem= /index.cfm?template=24hour5.cfm
cs-uri-query=<blank>
instead of
cs-uri-stem= /index.cfm
cs-uri-query=template=24hour5.cfm
Evidently something somewhere is interpreting the entire URL as a filename, instead of a file name and a query string. When CF tries to locate the file it is throwing a not-found error.
Maybe there is something weird about the question mark, but it looks normal to me.
I can't seem to stop this error, since it is occuring at the OS, IIS, CF or jrun layer. Does anyone have any idea what is going on here, and what I can do about it?
Thanks in advance.
JoeHey Reed, thanks for responding.
I have a Cf utility that parses logs, so I modifed it to print out the ASCII codes for each character. They look normal, as far as I can tell. The question mark has a code of 63 which is correct, and no non-alphabetic characters precede or follow.
One interesting thing is that the stem being called is an index.cfm file, and the query string argument happens to be a template name, and it ends in .cfm. That's why it is making it all the way to CF, which chokes on it, instead of IIS logging a 404 error.
Often an identifiable bot is requesting these bad URLs, though I have spotted another request with agent 'Mozilla/4.0.' I suspect that is some kind of automated scan. (I also see other requests with the same agent name, though a different IP, that look like errononeously URL-encoded requests. These get filtered by URLScan.)
I don't know for sure is whether the specific clients that make these bad calls always make them them wrong way. They appear to. Most clients that access the site do so normally.
I wonder if there could be something in the request header, perhaps that instructs IIS to expect a different charset than what is actually used, or something like that. -
Select-string and eliminate the file name of searched file
Is there a way with the select-string command to exclude the file name of the file you are searching and still get the line items that match your results?
Similar to the DOS find command results. I am trying to become completely independent of a DOS window and still have to find to reduce log files and make them easy to read.
Thanks
Chris
Chris J.Sure. Select-String returns MatchInfo objects, and the string value of the matched line is in the Line property of the objects.
Select-String -Pattern 'text to match' -Path 'filename.ext' |
Select -ExpandProperty Line
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " " -
InDesign CS4: File names change to string of numbers
Occasionally, one of our users will save an InDesign CS4 file, only to have the file name change. For example, a file originally named "#kwn25501.bcbsNM.indd" was saved as "#kwn25501.bc157-1223857848."
If the user is not aware that this has happened, things can go horribly, terribly wrong in our production environment. The "numbered" file may be missing key elements, or be somehow be corrupt in some fashion. In one case, this led us to having to reprint a job because the "numbered" file was missing a photo; somehow, that file was used (and perhaps renamed after the fact) to create the final output.
We use Macs running InDesign CS4 6.0.5. Some of our Macs are running Tiger 10.4.11, while others are running Leopard 10.5.8. The problem seems to related to the Leopard machines, although that is not 100 percent certain at this point. All of these Macs are bound to Active Directory and save files to a Windows 2003 server. I know Adobe recommends against working on files over a network, but perhaps there is an explanation for this file renaming aside from network issues.
Any light that can be shed on this issue will be greatly appreciated. Thanks!
Kevin StaufferCheck to see if maybe your original filename is the problem.
You may need that particular name for a workflow reason, but some of the symbols in the middle of your filename are generally not a good idea. Especially working off of a server, file names should be ONLY alpha-numeric characters, no symbols, no periods (except for the file type) and only underscores or dashes to separate words, no spaces.
The reason is some of those symbols get picked up as machine language and all sorts of bad can happen as a result.
Message was edited by: Michael Riordan -
GET FILE NAME C:\temp\ADIBO.txt
Hi,
How to get file name?
I used Get_File_NAME, but I'am getting an error.
lv_lfilename is not the type LOGICAL_FILENAME
C:\temp\ADIBO.txt
I need to get ADIBO ??
tnh, Adibo..:)
I am using this code to download file and after that I need to get FILE_NAME:
DATA: lv_lfilename TYPE string.
PARAMETERS:
pa_lfile TYPE zlocalfile
DEFAULT 'C:temp'.
CONCATENATE pa_lfile ''INTO lv_lfilename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_lfilename
filetype = 'ASC'
TABLES
data_tab = it_billit_down.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Hii..
You have to Maintain the Logical filenames and their Physical Paths in Tcode FILE.
Then create a program like this..
REPORT ZSEL_FILES1.
DATA : V_LOGFILE TYPE STRING.
DATA :V_PHYFILE TYPE STRING.
DATA : ITAB TYPE TABLE OF SCARR.
START-OF-SELECTION.
SELECT * FROM SCARR INTO TABLE ITAB.
**To get the Physical file based on the Logical file names - Maintained in Tcode FILE
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = VlOGFILE
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = ' '
PARAMETER_2 = ' '
PARAMETER_3 = ' '
USE_PRESENTATION_SERVER = ' '
WITH_FILE_EXTENSION = ' '
USE_BUFFER = ' '
ELEMINATE_BLANKS = 'X'
IMPORTING
EMERGENCY_FLAG =
FILE_FORMAT =
FILE_NAME = V_PHYFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**To download the file to PC.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = V_PHYFILE
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = ITAB
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>reward if helpful</b> -
Changing time stamp format in the file receiver adapter file name
Hi all,
How can we change the standard date time stamp from
filename_yyyymmdd-hhmmss-mil
to
filename_yymmdd_hhmmss
i.e., I want "underscores" instead of "hyphens" and also I do not want the MilliSeconds.
I read in the forums that I have to use the combination of variable substitution and mapping functions to do this, but not sure how exactly.
Can the experts help me with this please?
Many thanks.Hello Ramesh,
You can make this possible using runtime filename creation using UDF.
Please go though the below steps.
Message mapping:
Create an UDF and include the piece of code that captures the Filename and Timestamp from source side via ASMA.
Modify them according to our requirement by adding the <Timestamp> at the end of <filename> with _.
Map the UDF to any of the top level node so that the modified filename will be available for the target communication channel
UDF Code is:
try {
String filename = "";
String timestamp = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
DynamicConfigurationKey key2 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","SourceFileTimestamp");
filename = conf1.get(key1);
timestamp = conf1.get(key2);
filename = filenametimestamp".xml";
filename = filename.replaceAll( "-" ,"_" );
conf1.put(key1,filename);
return filename;
catch(Exception e)
String exception = e.toString();
return exception;
Click on Advanced tab and check the Option u201CSetAdapterSpecificMessageAttributesu201D in addition to that check the attribute that are required to be captured during run time. In our case File Name and Source File Time Stamp are required to be checked
In the receiver communication channel Mention u2018 * u2018as File Name Scheme.
Click on Advanced tab and check the Option u201CSetAdapterSpecificMessageAttributesu201D in addition to that check the attribute u201CFile Nameu201D which will carry the modified value in the UDF .
i hope this will help you.
Monica -
Can't search contents of files only file names.
I am really stuck guys. It's been aggrevating me for days. I tried to download 3rd party programs for searching in files and it still doesn't work. I checked the forums here and people only have trouble searching for kinds of files. Even when I use search strings like "contents" or "description" it still will only look for file names not contents.
It's frustrating because I am typing up my own personal book and I am in the process of fixing all the mistakes which requires searching by contents in my folder where my files are stored!
Thanks in advance!I've tried various file types.
I tried adding my HD to the list and literally waited 1 minuted but to no avail.
The next step is probably reinstalling Snow Leopard, right?
By the way, I mostly use Finder for searching, so how would I enable the indexing there? Or is it only spotlight that has this indexing thing? -
Search settings - default to current folder and "file name" ?
99.9% of the time, when I enter something in the search bar of the Finder window, what I want to do is:
1. search is the folder that I'm in
2. search for the "file name", and
3. then sort the results by "date modified".
Currently, problem is:
1. I can only change the search area (which defalts to "This Mac") after the search has begun.
2. Likewise, the default is "content"
3. There's not even an OPTION for "date modified". The "Last Opened" option is rarely useful.
Please help!
Thanks
ip
Message was edited by: ideapowerFrancine Schwieder wrote:
The only one who can help us is Apple. Obviously you find this just as ridiculous as everyone else does who actually uses their computer to do things.
While I usually think this kind of sweeping generalization is unjustified, here I do not. Spotlight has great potential, but "ridiculous" describes the implementation perfectly. I'm not terribly upset by the default to search "This Mac" -- it really isn't much of a hassle to have to click the folder button -- but the loss of the ability to choose any folder or group of folders is exactly the kind of "regressive functionality" that should have people flooding feedback with complaints.
Just as ridiculous is the inability to show & sort on any of the metadata columns a normal Finder window offers. And if "Last Opened" is so useful in searches that it is the (unchangeable) default, why isn't it available in any other Finder view?
Plus, does anybody really understand how the "File Name" option works? It rarely seems to make a difference -- I often enter a search phrase, look at the results, then switch to the File Name option & still see files that clearly do not have the search phrase or any part of it in their names.
More: Try a search on Kind "Other" & enter the "Kind" info from a file's Get Info Box. Try "Application (Classic)" & note that it finds any you might have. But try "Application (Universal)" or "Application (PowerPC)" & you get ... nothing. Try just "Application (" & you get all apps. Try "Classic" & once again, any Classic apps show up, but try "Universal" or "PowerPC" & you get nothing. It's the same with many other file kinds -- sometimes the "Get Info" file kind string or some part of it works, sometimes not. Worse, the same is true for the "Kind" info taken directly from Finder windows. Try entering "Plain Text" in the Kind-Other search. I have hundreds of these but the search turns up exactly one, & it isn't even in my Documents folder.
(Before anybody suggests it, yes I have rebuilt the Spotlight index repeatedly, using both the Privacy pane method & Terminal commands, & it makes no difference.)
The point is not to rant but to demonstrate how poorly thought out & unreliable the app remains. I feel the problems are so obvious & widespread that we should not have to use the feedback page to tell Apple about them, but apparently we do. It really is as if it was designed by people that don't have a clue about what a search engine should do or how to integrate it into a user friendly environment. -
Change file name with oreilly servlet
I am using oreilly servlet package and I want to change the file name to the file I am uploading, is this possible ?
How ?
Thanks.
here I post the servlet code:
package com.reducativa.sitio.servlets;
* DemoParserUploadServlet.java
* Example servlet to handle file uploads using MultipartParser for
* decoding the incoming multipart/form-data stream
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import com.oreilly.servlet.multipart.*;
public class DemoParserUploadServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
out.println("Demo Parser Upload Servlet");
File dir = new File("f:/");
if (! dir.isDirectory()) {
throw new ServletException("Supplied uploadDir " + "f:/ " +
" is invalid");
try {
MultipartParser mp = new MultipartParser(request, 10*1024*1024); // 10MB
Part part;
while ((part = mp.readNextPart()) != null) {
String name = part.getName();
if (part.isParam()) {
// it's a parameter part
ParamPart paramPart = (ParamPart) part;
String value = paramPart.getStringValue();
out.println("param; name=" + name + ", value=" + value);
else if (part.isFile()) {
// it's a file part
FilePart filePart = (FilePart) part;
String fileName = filePart.getFileName();
if (fileName != null) {
// the part actually contained a file
long size = filePart.writeTo(dir);
out.println("file; name=" + name + "; filename=" + fileName +
", filePath=" + filePart.getFilePath() +
", content type=" + filePart.getContentType() +
", size=" + size);
else {
// the field did not contain a file
out.println("file; name=" + name + "; EMPTY");
out.flush();
catch (IOException lEx) {
this.getServletContext().log("error reading or saving file");
}Hi there,
I am facing the same problem that you have stated in your Feb 26, 2002 10:28 AM message regarding "change file name with oreilly servlet", I would like to change the file name to include a unique identifier upon upload, did you ever find a solution to your problem?
Thanks!
Todd
[email protected]
Maybe you are looking for
-
I just bought a new IPhone 5-had tp update the operating system to be able to sync it with my axisting phone which was on 6.1 (new phone was on 6.0.1). So the new phone is now synced to an old version of my old phone that was on ITunes...how do I ge
-
How to convert spool request to pdf format (to send mail) - SAP 3.1H
Hi, I am working in 3.1H version. How to convert spool request into pdf cormat to send a mail?. Spool request is in TEXT format. regards, sundaram J.
-
In my BSP, there is a method of a particular class being used to populate some table which is being displayed in the front end. I want to set a break-point on the method so I could see on runtime how & from where is it fetching data. Could anyone gui
-
Corrupted diacritical accents in iTunes 7.7
I updated to iTunes 7.7 and discovered that the diacritical accents in the mp3 tags have been corrupted. Most of the accented characters look normal in the play window, but when I open info for any mp3, I get strange-looking characters. If the accent
-
Odi Variable with dynamical refreshing(Solved)
Hi, I have a ODI variable used in 3 packages. This variable get number of records of the table, but table changes. Example: if package A Variable refreshing with select count(1) from TABLE_SYS if package B Variable refreshing with select count(1) fro