How to get file encoding type
Hi ,
How to get the file encoding type,
for example file is saved with the .txt and encoding is utf-8 and another file is saved .txt with encoding is ascii,
actually before reading the file i want idetify the encoding type
please help me it is very urgent for me..
thanks in advance
As there is no established regime for signing most encoding types, the only way to do this is to start parsing the file in one encoding, see if you get something that makes sense, and if not try another encoding, and so on. I.e. you have to code it yourself and even then it is not usually reliable. Sorry.
Drake
Similar Messages
-
How to get the "encoding" of a XML file using JDOM
As in XML file, <?xml version="1.0" encoding="UTF-8" ?> indicates the encoding of this file
while using JDOM to parse a XML file, how can I get the encoding type?
thanx!!!What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
Thanx all for your help and attention!!! -
How to get File type icon for files store on Amazons3
Hi,
i want to know about how to get file type icons for files that we store on Amazons3.i am a devloper ,i want to make gui for accessing amazons3.
so ,i want to know about how to get file type icons for files that we store on Amazons3.
thanx in advance.hi,
have u heard amazon simple storage service,that provides storage space for
storing files, i am a devloper,i want to know the files that we store on amazon,how we can get file type icon for that files.
i want to sample code in java for this.
thanx in advance. -
How to get file attribs - on any Mac
ok so if the Mac in question has Developer / Tools - yeah the GetFileInfo binary will work to get the Type and Creator code and other info.... since most Macs dont have this bulky download... how to get file attribute information via Terminal ? How to change it ?
Oddly enough I was just now playing around with a getinfo Applescript and studying the event log when I realized that it does return information about at least some of the attributes. I made the ones that it looks like you can get information about bold:
A Alias file
B Bundle
C Custom icon
D Desktop
E Hidden extension
I Inited
M Shared (can run multiple times)
N No INIT resources
L Locked
S System (name locked)
T Stationary
V Invisible
Z Busy
If you are interested see this thread:
http://discussions.apple.com/message.jspa?messageID=5261906#5261906
The SetFile function is actually available on any Mac that has a recent Tiger updater package installed. Thus I have copies in both the package updaters and the receipts for 10.4.7, .8, .9 and .10 in the /Library/Packages and /Library/Receipts folders. The SetFile command is in the Resources folder:
"/Library/Packages/MacOSXUpd10.4.10PPC.pkg/Contents/Resources/SetFile"
Control click on the .pkg file and select Show contents from the Contextual Menu to get there. Unfortunately I don't know of any way to use some other Terminal command to get information on all the attributes, except the GetFileInfo and using the Applescipt get info function.
Francine
Francine
Schwieder -
How to get file from server while click on link
Hi,
i created on link and i gave one server path to select file from server but while clickinng on link it no displaying any thing.
following is the Destination url that i gave for the item.
/u08/app/appvis/xxex/inst/xxex_apps/xxrbe/logs/appl/conc/log/
please tell me how to get file from server while click on link.Ok I got your requirement now.
If you are getting file names from view attribute then you should not be adding destination URI property for the link.
Instead you can use OADataBoundValueViewObject API.
Try below code in your controller processRequest method:
I am assuming that you are using classic table.
Also in below example it considers OAMessageStyleText and you can replace it with link item if you want.
OATableBean tableBean =
(OATableBean)webBean.findChildRecursive("<table item id>");
OAMessageStyledTextBean m= (OAMessageStyledTextBean)tableBean.findChildRecursive("<message styled text in table item id>");
OADataBoundValueViewObject tip1 = new OADataBoundValueViewObject(m, "/u08/app/appvis/xxex/inst/xxex_apps/xxrbe/logs/appl/conc/log/"+"<vo attr name which stores file name for each row>");
m.setAttributeValue(oracle.cabo.ui.UIConstants.DESTINATION_ATTR, tip1);
Regards,
Sandeep M. -
How to get file count in variable?
dear all,
how to get file count in variable?
regards
NaseerHi Nazeer ,
It wont take much time .. so simple :- )
Create one os comand step
( for unix) Use
wc -l filename.txt > someoutputfile.txt
Now the number of lines in your file will be there in the output file ( someoutputfile.txt )
Step2 :-
Now use Cezar's logic to fetch the variable value ( file count ) from the output file .. ( select value for a variable from a file )
This will not take eeven a second to finish the job.
Regards,
Rathish A M -
How to get the Database type from weblogic Db connection
I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
What my question is how to get the database type from the connection.For a normal jdbc driver you can use
Connection.getMetaData()
To get the meta data, in particular the getDatabase...() methods.
That might or might not work.
However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out. -
How to get file line count.
Hey guys,
How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
Is there any other methods?
Thanks in advace!What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
InfoFetcher.java
============
package tjacobs.io;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
* InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
* InfoFetcher can be set up with a thread so that it reads from an input stream
* and report to registered listeners as it gets
* more information. This vastly simplifies the process of always re-writing
* the same code for reading from an input stream.
* <p>
* I use this all over
public class InfoFetcher implements Runnable {
public byte[] buf;
public InputStream in;
public int waitTime;
private ArrayList mListeners;
public int got = 0;
protected boolean mClearBufferFlag = false;
public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
this.buf = buf;
this.in = in;
this.waitTime = waitTime;
public void addInputStreamListener(InputStreamListener fll) {
if (mListeners == null) {
mListeners = new ArrayList(2);
if (!mListeners.contains(fll)) {
mListeners.add(fll);
public void removeInputStreamListener(InputStreamListener fll) {
if (mListeners == null) {
return;
mListeners.remove(fll);
public byte[] readCompletely() {
run();
return buf;
public int got() {
return got;
public void run() {
if (waitTime > 0) {
TimeOut to = new TimeOut(waitTime);
Thread t = new Thread(to);
t.start();
int b;
try {
while ((b = in.read()) != -1) {
if (got + 1 > buf.length) {
buf = IOUtils.expandBuf(buf);
int start = got;
buf[got++] = (byte) b;
int available = in.available();
//System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
if (got + available > buf.length) {
buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
got += in.read(buf, got, available);
signalListeners(false, start);
if (mClearBufferFlag) {
mClearBufferFlag = false;
got = 0;
} catch (IOException iox) {
throw new PartialReadException(got, buf.length);
} finally {
buf = IOUtils.trimBuf(buf, got);
signalListeners(true);
private void setClearBufferFlag(boolean status) {
mClearBufferFlag = status;
public void clearBuffer() {
setClearBufferFlag(true);
private void signalListeners(boolean over) {
signalListeners (over, 0);
private void signalListeners(boolean over, int start) {
if (mListeners != null) {
Iterator i = mListeners.iterator();
InputStreamEvent ev = new InputStreamEvent(got, buf, start);
//System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
while (i.hasNext()) {
InputStreamListener fll = (InputStreamListener) i.next();
if (over) {
fll.gotAll(ev);
} else {
fll.gotMore(ev);
InputStreamListener.java
====================
package tjacobs.io;
public interface InputStreamListener {
* the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
public void gotMore(InputStreamEvent ev);
* reading has finished. The entire contents read from the stream in
* in the buffer
public void gotAll(InputStreamEvent ev);
InputStreamEvent
===============
package tjacobs.io;
* The InputStreamEvent fired from the InfoFetcher
* the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
public class InputStreamEvent {
public int totalBytesRetrieved;
public int start;
public byte buffer[];
public InputStreamEvent (int bytes, byte buf[]) {
this(bytes, buf, 0);
public InputStreamEvent (int bytes, byte buf[], int start) {
totalBytesRetrieved = bytes;
buffer = buf;
this.start = start;
public int getBytesRetrieved() {
return totalBytesRetrieved;
public int getStart() {
return start;
public byte[] getBytes() {
return buffer;
ParialReadException
=================
package tjacobs.io;
public class PartialReadException extends RuntimeException {
public PartialReadException(int got, int total) {
super("Got " + got + " of " + total + " bytes");
} -
Is it possible to get file encoding?
I am working with windows netsh util
/**filename = path to file*/
private static BufferedReader readFileWithBufferedReader(String filename){
FileInputStream fis = null;
InputStreamReader sr= null;
BufferedReader r = null;
try {
fis = new FileInputStream(filename);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}//fis catch
try {
/*creating InputStreamReader with encoding param*/
sr = new InputStreamReader(fis, "Cp866" /*"Cp1251"*/);
System.out.println("encoding ::: " +sr.getEncoding());
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}//sr catch
/*wrapping to BufferedReader*/
br = new BufferedReader( sr);
System.out.println("YES!!!");
return br;
}I get InputStream from console. I set encoding as "cp866" (it's O.K.)
Then, I save stream to file.
Then user can open this file and get config from file.
The problem is in open file procedure.
I do not know file encoding: it can be "cp1251" (windows cyrillic) or it can be "cp866" (cmd output).
So if user tries to open "cp1251" file with "cp866" encoding, he gets unreadable characters.
Is it possible to get file encoding and then re-create InputStreamReader with proper encoding?Well, you can't get the file encoding. It's not saved with the file. Unless it's your file format, in which case you can save whatever you want.
There are apps that can guess a file's encoding.
Of course, if you have control over the files entirely, it shouldn't be a problem, and generally it'd make life a lot easier to just use UTF-8.
So if user tries to open "cp1251" file with "cp866" encoding,
he gets unreadable characters.what if you read a "cp866" with "cp1251" encoding? -
How to get the Mime Type of the file?
Hi Everyone!,
I want to upload a random file into my table as a BLOB and simultaneously want to fill the respective another column with its MimeType. Earlier I used Oracle Apex for this, but due to my new requirement I need to make this happen with the help of PL SQL and Forms. Could you help me in getting how we can upload the file and most importantly, how we can get its Mime-Type.
My chosen file can be of any type; it can be doc ,pdf,txt,xls ,gif or any other format.
If you could provide the example with your reply then it would be great.
Thanks
Harbinderhi
for that u have to use webutil.
declare
f varchar2(100);
begin
f := webutil_file.file_open_dialog();
if f is not null then
:doc.doc_name := f;
end if;
end;and
DECLARE
filename VARCHAR2(256);
BEGIN
filename := CLIENT_GET_FILE_NAME (File_Filter => 'jpg (*.jpg)|*.*|');
READ_IMAGE_FILE(filename, 'jpg', 'image');
END; sarah -
How to get the encoding of a XML file ...
Hi,
How do you get the encoding of a XML file?
For example,
<?xml version="1.0" encoding="SJIS"?>
I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
Thanks in advance for any help,
EricHi ddossot,
Thanks for your suggestion.
However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
Regards,
Eric -
How to Get File type in webdynpro abap
Hi,
I am using File Upload UI element of webdynpro ABAP to upload data into SAP table. I want that the file type should only be tab delimited. How to get the file type to validate the same.
Regards,
Dhiraj Mehtahi,
just follow the link :
http://help.sap.com/saphelp_40b/helpdata/en/2a/fa02b7493111d182b70000e829fbfe/content.htm
Hope this will help u!!!
thanks & regards,
punit raval. -
How to get the MIME type of the given file in R/3
Dear Experts,
Please tell me the FM or Class to get the given file MIME type in R/3 . I am using GUI_upload Function module to upload the file in R/3 .
Edited by: balaji ramadas on Jan 16, 2009 5:39 AMThank you Prosenjit I m using this FM CV120_GET_MIME_TYPE
to get the MIME type of the file
regards,
Balaji.R
Edited by: balaji ramadas on Jan 19, 2009 9:24 AM -
How to change the Encoding type of a XML
Hi all,
I'm having a XML(generated at run time) with UTF-8 Encoding. If I'm going to parse it, getting an error saying "*Document root element is missing*".
If I change the encoding to ANSI, it parses without error.
How can I change the encoding type of a documnet ?
Any comment welcome.
KaushalyaThere's no such thing as the "encoding of a String". If you produced a String from a sequence of bytes using the wrong encoding, you may not be able to repair that problem by hacking about in your code. You're better off to produce the String using the correct encoding in the first place. Read this for more information about XML and encodings as you appear to be misunderstanding basic concepts:
[http://skew.org/xml/tutorial/] -
How to get the Data type of the Internal Table.
How can i get the data types used to create an internal table
TYPES : BEGIN OF t_makt,
matnr TYPE matnr,
maktx TYPE maktx,
END OF t_makt.
Like this some function will give me which data types i have used for the internal table at run time.Use the FM ..
data : int_fcat type SLIS_T_FIELDCAT_ALV.
REUSE_ALV_FIELDCATALOG_MERGE ..
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'IMAT' <-- this is your internal table
I_INCLNAME = sy-repid
CHANGING
CT_FIELDCAT = int_fcat <--- this contains all the fields along with their characteristics ...
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Maybe you are looking for
-
CUCM 8.6.2 -- DRS: TAR File Not Created
Hey, I am having trouble running my CUCM backups. The Unity backups, however, are running fine. I get completely through the Publisher, but I fail everytime on the TFTP backup on the first Subscriber node. I am using freeFTPd as a service on a Win
-
Need some advice on a new build for CS5 Web Premium
I am looking for a powerful PC that I can use mostly for work and some light video work. I have been looking at several systems, but I can't decide if I should get the Core i7 875K, 950 or AMD 1090T for my needs. I typically have many Adobe CS5
-
Safari crashes on launch - EXC_BAD_ACCESS (0x0001) - Thread 0 Crashed:
Safari fails to launch - have tried several times. I have also checked on forums, etc, and have tried deleting the appropriate .plist files; have also downloaded OnyX and run various cleaning and maintenance processes. I have also tried creating a ne
-
I am running windows 8, 64 bit, & suddenly have a problem opening files, I have to keep re-booting - is there anything in preferences I can change?
-
How do I make a cell equal a certain degree of a 360° zodiac point?
I need to make a cell equal a certain degree on a 360° zodiac point when typing a number from 0-359. For example, if I would put in the number "10" in a cell it would give me "10 Aries" as a result in the cell. Doing 360 "if, then" statements is not