Reading text files without specifying the encoding?
I have looked everywhere for a solution, but I can't find one. The problem is that I'm using codes that everybody is using, but for some reason, my codes aren't working.
I want to be able to open up text files in Java without having to specify the encoding for the files that I'm going read, because I have no idea which encoding they will use.
But even when specifying UTF-8 to be encoding of the file to read, it doesn't work correctly:
FileInputStream fileIS= new FileInputStream("somefile.txt");
Reader reader = new BufferedReader(new InputStreamReader(fileIS, Charset.forName("UTF-8")));
EVERYWHERE I look, ppl are using these codes! But it doesn't work, some characters (such as the Euro sign) are displayed as squares.
However, I want to be able to read not only UTF-8 files but anything that Java supports. Any ideas?
Edited by: Stalfos on Oct 22, 2007 12:22 PM
Stalfos wrote:
I want to be able to open up text files in Java without having to specify the encoding for the files that I'm going read, because I have no idea which encoding they will use.
This is your problem. If you don't know what encoding the text is stored in, then the chances that the default encoding used to read it will be correct are slim.
But even when specifying UTF-8 to be encoding of the file to read, it doesn't work correctly:There are many different character encodings, and most of them don't overlap. Anything above 127 usually causes problems.
FileInputStream fileIS= new FileInputStream("somefile.txt");
Reader reader = new BufferedReader(new InputStreamReader(fileIS, Charset.forName("UTF-8")));
EVERYWHERE I look, ppl are using these codes! But it doesn't work, some characters (such as the Euro sign) are displayed as squares.The problem isn't with the code, it's that the file you're reading isn't using an encoding that's compatible with UTF-8. Assuming that using UTF-8 should work for all encodings is like assuming that someone who can read Chinese should be able to read a book written in Spanish or Greek. It doesn't work that way.
However, I want to be able to read not only UTF-8 files but anything that Java supports. Any ideas?You need to know what encoding your files are stored in, period. There are a few ways to guess what the encoding is, but they're only reliable for a small set of encodings.
You don't seem to truly understand what character encodings are, or how to use them, so read this:
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
http://www.joelonsoftware.com/articles/Unicode.html
Similar Messages
-
Read a text file before knowing the encoding
Hi,
I've wrote a AppleScript to adjust time delay of *.lrc file(txt file but different extension).I only got a messed up text, in other aspect, it works well. I understand applescript read the text file using the wrong encoding, but I can't just set the encoding to UTF-8, for it can be UTF-8 and it can be Shift-JIS, Big5 andGB18030 as well. I don't know how to open text without getting messed up and write the result to a new text file on desktop using UTF-8 encoding. Can anyone help me with this? Thanks in advance.
Code:
on run
set _lrcFile to (choose file)'s POSIX path
display dialog "Time to delay (sec):" with title "Adjust LRC Delay" default answer "-0.5"
set _timeDelay to text returned of result
try
set _timeDelay to _timeDelay as real
on error
display dialog "Input must be a real" with title "Error" buttons {"Stop"} default button "Stop"
error number -128
end try
set _paraList to paragraphs of (read POSIX file _lrcFile)-->I don't know how to read text file properly here.
set _newLrc to ""
repeat with _para in _paraList
set _timecode to do shell script "sed 's/\\[\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}.[0-9]\\{2\\}\\)\\]\\(.*\\)/\\1 \\2/'<<<" & quoted form of _para
if _timecode as string is not (contents of _para) then
set _timecode to words of _timecode
set _min to (item 1 of _timecode) as integer
set _sec to (item 2 of _timecode) as real
set _sec to _sec + _timeDelay
set _min to _min + _sec div 60
set _sec to _sec mod 60
set _sec to (round (_sec * 100)) / 100
if _min < 10 then
set _min to "0" & _min as string
else
set _min to _min as string
end if
if _sec < 0 then
set _sec to "00.00"
else if _sec < 10 then
set _sec to "0" & _sec as string
else
set _sec to _sec as string
end if
if (count of _sec) < 5 then
set _sec to _sec & "0"
end if
set _lyrics to do shell script "sed 's/\\[\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}.[0-9]\\{2\\}\\)\\]\\(.*\\)/\\3/'<<<" & quoted form of _para
set _newLrc to _newLrc & "[" & _min & ":" & _sec & "]" & _lyrics & return
else
set _newLrc to _newLrc & contents of _para & return
end if
end repeat
-->write _newLrc to destop here (using UTF-8 encoding)
end run
Sample of *.lrc and the result after delaying 0.5s.Hope this post will help people doing their homeworks...
StringBuffer tmpBuffer = new StringBuffer();
try {
URL url = new URL("http://.../test.txt");
URLConnection urlconnection = url.openConnection();
long l = urlconnection.getContentLength();
tmpBuffer.append("Content Length = " + l);
BufferedReader in =
new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = in.readLine()) != null) {
tmpBuffer.append("\n" + line);
in.close();
} catch (Exception e) {
//System.out.println(e.toString());
if (tmpBuffer != null) {
wdContext.currentContextElement().setZoneMessage(
tmpBuffer.toString()); -
TEXT_IO.FOPEN how to pick file without specifying the full directory path
Hi,
I am using Oracle application server 10gR2 on Linux with forms 10g application. I am building the DEV/TEST/UAT environment on same Linux machine with one OAS.
I am using TEXT_IO.FOPEN ('/home/oracle/check.txt','r') to read a server side file and it is working fine.
Now I want to pick this file dynamically i.e. without specifying the full path. I am using TEXT_IO.FOPEN ('check.txt','r') and I copied file in forms_path directory in linux and even in $path directory in linux but none of them are working.
Pls help me sort out this problem.
Thanks in advanceHi,
I have to read files in my app directory using TEXT_IO how is that possible?? I cannot set workingDirectory as my Oracle home is in a different location and as has been mentioned by others when I run the form on web it cannot seem to find the file in the default forms directory where all the .fmx file
Is there any other file setting that needs to be done??
Please help
Thanks & Regards
Mangesh Deshpande -
How to export to text file without ruin the format
Hi guys,
I need some help here. My company recently come with the decision to print the mainframe report file that usually come as a text file, to a virtual printer. This virtual printer is printing the report as Adobe PDF format. The problem is, my Line of Business have a macros on Excell file that will grab the information from the text file to be processed in the Excell format. I tried to use Adobe Professional 8 to re-convert the PDF file to be text file, but the result is, most of the blank space is gone, and it is align to left, thus make it unusable to the Excell file.
Unfortunately, I can't provide you the sample of the document, because it contain classified customer info.
But appreciate if you can give me some advice.
Thanks and Regards.It sounds as if you are dealing with untagged PDF.
Tagged output PDFs, with a well-formed structure, provide (amoung other things) the ability to Save As/Export
content to some other applications with all or most of the layout/format intact.
I suspect that the output PDFs you have are untagged.
As there is, currently, a rather limited number of applications that support adequate tag management
(FrameMaker, InDesign, MS Word (via Adobe's PDFMaker & to a much lesser extent with Office Save As to PDF - XPS)
I suspect the mechanism used to provide your PDFs won't cut it with regards to providing a tagged output PDF having a
well-fomed structure (which would include dictionaries containing format/layout data).
As alluded to by Bernd, there may be third party plug-ins that might help.
The more reliable/functional ones tend to not be inexpensive.
Be well... -
How to read text file flash memory
Use the 'more' command. Here is a console log showing it in use -
VG202#dir flash:
Directory of flash:/
1 -rw- 18955952 Mar 1 2002 00:19:50 +00:00 vg20x-ipvoice-mz.124-22.T.
bin
128843776 bytes total (109887488 bytes free)
VG202#copy run flash:Myconfig.txt
Destination filename [Myconfig.txt]?
1593 bytes copied in 0.392 secs (4064 bytes/sec)
VG202#dir flash:
Directory of flash:/
2 -rw- 1593 Mar 6 2002 19:28:26 +00:00 Myconfig.txt
1 -rw- 18955952 Mar 1 2002 00:19:50 +00:00 vg20x-ipvoice-mz.124-22.T.
bin
128843776 bytes total (109883392 bytes free)
VG202#
VG202#more flash:Myconfig.txt
version 12.4
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
hostname VG202
boot-start-marker
boot-end-marker
logging message-counter syslog
enable password cisco
no aaa new-model
ip source-route
ip cef
no ipv6 cef
stcapp ccm-group 1
stcapp
stcapp feature access-code
stcapp feature speed-dial
stcapp call-control mode feature
voice-card 0
archive
log config
hidekeys
interface FastEthernet0/0
ip address 10.66.75.41 255.255.255.0
duplex auto
speed auto
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 10.66.75.1
no ip http server
control-plane
voice-port 0/0
timeouts initial 60
timeouts interdigit 60
timeouts ringing infinity
voice-port 0/1
ccm-manager fax protocol cisco
ccm-manager config server 10.66.90.130
ccm-manager config
ccm-manager sccp local FastEthernet0/0
ccm-manager sccp
mgcp fax t38 ecm
sccp local FastEthernet0/0
sccp ccm 10.66.75.212 identifier 2 version 6.0
sccp ccm 10.66.75.211 identifier 1 version 6.0
sccp
sccp ccm group 1
associate ccm 1 priority 1
associate ccm 2 priority 2
dial-peer voice 1 pots
service stcapp
port 0/0
dial-peer voice 10 pots
shutdown
destination-pattern 10
port 0/1
dial-peer voice 11 pots
shutdown
destination-pattern 11
port 0/0
line con 0
no modem enable
line aux 0
line vty 0 4
password cisco
login
exception data-corruption buffer truncate
end
VG202# -
The program doest enterpret my figures from the text file in the correct way since the numbers contain dots instead of commas. Is there a way to fix this in labVIEW, or do I have to change the files before reading them in the program? Thanks beforehend!
You must go in the labview option menu, you can select 'use the local
separator' in the front side submenu (LV6i).
If you use the "From Exponential/Fract/Eng" vi, you are able to select this
opton (with a boolean) without changing the labview parameters.
(sorry for my english)
Lange Jerome
FRANCE
"Nina" a ecrit dans le message news:
[email protected]..
> I would like to read a text file in which the decimal numbers are
> using dots instead of commas. Is there a way of converting this in
> labVIEW, or how can I get the program to enterpret the figures in the
> correct way?
>
> The program doest enterpret my figures from the text file in the
> correct way since the numbers contain dots instea
d of commas. Is there
> a way to fix this in labVIEW, or do I have to change the files before
> reading them in the program? Thanks beforehend! -
How to export the text edit data to excel file without splitting the data in excel file?
how to export the text edit data to excel file without splitting the data in excel file?
I have a requirement in SAP HR where in the appraiser can add comments in the area given and can export that to excel file. Currently the file is getting exported but the comments getting split into deifferent rows.
I want the entire comment to be fit in one row.
Please help.
Thank youHi,
if your text edit value is stored in 'lv_string' variable.
then before exporting the value to excel you have to remove CL_ABAP_CHAR_UTILITIES=>NEWLINE
that is '#' from the variable lv_string.
for that use code some thing like this.
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE in lv_string WITH space.
I think this will do the trick. -
Is it possible to read/write to text file without deleting it?
I know how to read from a text file and how to write to a text file. The problem that i have is i need to use a text file to store data for my application to read and also for my application to write. I would like it if i could write two programs really, one reads, the other is used to update the text file. This file is a list of verbs. I thought about using databases but i couldn't get them to work. I downloaded MySQL server 5.0 and installed it. I then downloaded the driver from http://www.mysql.com/products/driver and ran the auto installer. it said everything worked out perfectly but when i try these lines:
Class.forName("com.mysql.jdbc.Driver");
I get a SQLException that says no suitible driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
( I thought this driver came with the JDK but i guess not, i just read about it in a java book)
I get a ClassNotFoundException
that just says sun.jdbc.odbc.JdbcOdbcDriver
So yeah, SQL is pretty much not working. I need a solution to my problem, either by using text files, or a different type of database. I heard you could use excel to create a database but i have no idea how and i hear microsoft access could also do this, however i don't have microsoft access and i don't intend on paying for it. So, here are my questions:
1st, is there a tutorial on using excel databases in java programs
(if not)
2nd is there a way to read/write/update a text file without deleting it?
(if not)
3rd is there a way to get SQL working, i have windows vista this could be the problem
(if not)
4th what could i do to store information on the hd for reading and modifying later?
thanks, lateralusA database might be overkill just for a list of words.
Thoughts:
<ul>
<li>What is the extent of your "file updating"? If you are just appending to the file, opening it in append mode will keep the file from being clobbered.</li>
<li>Otherwise, why not create new files instead of editting them? The file names could include a version number or timestamp, allowing the reader to select the newest one.
</li>
</ul> -
How can I read text files from LAN if I only know the hostname?
I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
<p>1. How can I read text files from LAN if I only know the hostname, or IP address?
<p>2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.
(ex. how can I read the 120th line?)
<p>Please help!
<p>sorry for the bad englishI'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
1. How can I read text files from LAN if I only know the hostname, or IP address?You need to know the URL of the file. You need to know the hostname, port, protocl and relative path.
The hostname is server, not file.
2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.Use the seek() to get to a random byte.
(ex. how can I read the 120th line?)The only way to find the 120th line is to read the first 120 lines. You can use other file formats to find the 120th line without reading the whole file but to need to be able to detremine where the 120th line is -
How can i read the text files and buffer the data in Vector?
hi. I have been running into this problem for days, but with no luck and losing right direction.
The problem is : I am trying to read a text file and buffer the data into a
Queue for each user.
the sample text file is as below:( 1st column is timestamp, 2nd is user_id, 3rd is packet_id, 4th is packet_seqno, 5th is packet_size)
0 1 1 1 512
1 2 1 2 512
2 3 1 3 512
3 4 1 4 512
4 5 1 5 512
5 6 1 6 512
6 7 1 7 512
7 8 1 8 512
8 9 1 9 512
9 10 1 10 512
10 1 2 11 512
11 2 2 12 512
12 3 2 13 512
13 4 2 14 512
14 5 2 15 512
15 6 2 16 512
16 7 2 17 512
17 8 2 18 512
18 9 2 19 512
19 10 2 20 512
20 1 3 21 512
21 2 3 22 512
22 3 3 23 512
23 4 3 24 512
24 5 3 25 512
25 6 3 26 512
26 7 3 27 512
27 8 3 28 512
28 9 3 29 512
29 10 3 30 512
30 1 4 31 512
31 2 4 32 512
32 3 4 33 512
33 4 4 34 512
34 5 4 35 512
35 6 4 36 512
36 7 4 37 512
37 8 4 38 512
38 9 4 39 512
39 10 4 40 512
40 1 5 41 512
41 2 5 42 512
42 3 5 43 512
43 4 5 44 512
44 5 5 45 512
45 6 5 46 512
46 7 5 47 512
47 8 5 48 512
48 9 5 49 512
49 10 5 50 512
50 1 6 51 512
51 2 6 52 512
52 3 6 53 512
53 4 6 54 512
54 5 6 55 512
55 6 6 56 512
56 7 6 57 512
57 8 6 58 512
58 9 6 59 512
59 10 6 60 512
60 1 7 61 512
61 2 7 62 512
62 3 7 63 512
63 4 7 64 512
64 5 7 65 512
65 6 7 66 512
66 7 7 67 512
67 8 7 68 512
68 9 7 69 512
69 10 7 70 512
70 1 8 71 512
71 2 8 72 512
What I wanna do is to read all the data above and buffer them in a queue for each user( there are only 10 users in total).
I already created a class called Class packet:
public class packet {
private int timestamp;
private int user_id;
private int packet_id;
private int packet_seqno;
private int packet_size;
/** Creates a new instance of packet */
public packet(int timestamp,int user_id, int packet_id,int packet_seqno, int packet_size)
this.timestamp = timestamp;
this.user_id=user_id;
this.packet_id=packet_id;
this.packet_seqno=packet_seqno;
this.packet_size=packet_size;
}then I wanna to create another Class called Class user which I can create a queue for each user (10 users in total) to store type packet information. the queue for each user will be in the order by timestamp.
any idea and sample code will be appreciated.Doesn't sound too hard to me. Your class User (the convention says to capitalize class names) will have an ArrayList or Vector in it to represent the queue, and a method to store a Packet object into the List. An array or ArrayList or Vector will hold the 10 user objects. You will find the right user object from packet.user_id and call the method.
Please try to write some code yourself. You won't learn anything from having someone else write it for you. Look at sample code using ArrayList and Vector, there's plenty out there. Post in the forum again if your code turns out not to behave. -
Numbers to CSV export script: how to specify the encoding?
Hi,
I'm using the following script to export a Numbers document to CSV:
# Command-line tool to convert an iWork '09 Numbers
# document to CSV.
# Parameters:
# - input: Numbers input file
# - output: CSV output file
# Attik System, Philippe Lang
# Creation date: 31 mai 2012
# Modification date:
on run argv
# We retreive the path of the script
set myPath to (path to me)
tell application "Finder" to set myFolder to folder of myPath
# We get the command line parameters
set input_file to item 1 of argv
set output_file to item 2 of argv
# We retreive the extension of the file
set theInfo to (info for (input_file))
set extname to name extension of (theInfo)
# Paths
set input_file_path to (myFolder as text) & input_file
set output_file_path to (myFolder as text) & output_file
if extname is equal to "numbers" then
tell application "Numbers"
open input_file_path
save document 1 as "LSDocumentTypeCSV" in output_file_path
close every window saving no
end tell
end if
end run
It works fine, except that I don't know how to specify the encoding of the text in the CSV file (Latin1, MacRoman, Unicode). This option is available in the export dialog of Numbers. Any hint on how to do that is welcome. (GUI Scripting?)
Where can I find documentation on the iWork "vocabulary" available? Is there a definitive documentation somewhere? I tried to record an manual export in the script editor, without success. Script is more or less empty.
Thanks!
Philippe LangA further note from Yvan. He's made some revisions to the script sent earlier.
--{code}
--[SCRIPT export to CSV with selected encoding]
I added some features.
(1) Defining the encoding thru the preferences file apply only if
the application is not in use because the file is read only once in a session.
A test urge you to quit Numbers if it is running.
(2) info for is deprecated so it may be removed by Apple tomorrow.
I no longer use it.
(3) just for the fun, I added a piece of code allowing you to select the encoding on the fly.
Thanks to the property chooseEncodingInScript, at this time the script use Unicode (UTF-8)
(4) I'm wondering which tool is used to launch this script,
I don't know the way to pass arguments when I run one.
Yvan KOENIG (VALLAURIS, France)
2012/06/13
property chooseEncodingInScript : false
true = the script will ask you to select the encoding
false = the script use the embedded encoding
on run argv
set input_file to (item 1 of argv) as text
set output_file to (item 2 of argv) as text
set myPath to (path to me) as text
tell application "System Events"
set theProcesses to name of every application process
set myFolder to path of container of (disk item myPath)
set input_file_path to myFolder & input_file
set output_file_path to myFolder & output_file
set extname to name extension of (disk item input_file)
end tell
if extname is "numbers" then
if "Numbers" is in theProcesses then error "Please, quit “Numbers” before running this script !"
if chooseEncodingInScript then
set theList to {"Mac OS Roman", "Unicode (UTF-8)", "Windows Latin 1"}
set maybe to choose from list theList with prompt "Choose the default encoding applying to export as CSV"
if maybe is false then
error number -128
else if item 1 of maybe is item 1 of theList then
30 -- Mac OS Roman
else if item 1 of maybe is item 2 of theList then
4 -- Unicode (UTF-8)
else
12 -- Windows Latin 1
end if
else
4 -- Unicode (UTF-8)
end if
do shell script "defaults write com.apple.iWork.Numbers CSVExportEncoding -int " & result
tell application "Numbers"
open input_file_path
save document 1 as "LSDocumentTypeCSV" in output_file_path
close every window saving no
end tell
end if
end run
--{code}
Regards,
Barry -
Reading Outlook files without Outlook
Hi, I'm looking for recommendations for alternative software for Outlook. I don't have it, but I receive Outlook files I need to read. Are there any viable alternatives to Outlook to access the files? Thanks!
Stalfos wrote:
I want to be able to open up text files in Java without having to specify the encoding for the files that I'm going read, because I have no idea which encoding they will use.
This is your problem. If you don't know what encoding the text is stored in, then the chances that the default encoding used to read it will be correct are slim.
But even when specifying UTF-8 to be encoding of the file to read, it doesn't work correctly:There are many different character encodings, and most of them don't overlap. Anything above 127 usually causes problems.
FileInputStream fileIS= new FileInputStream("somefile.txt");
Reader reader = new BufferedReader(new InputStreamReader(fileIS, Charset.forName("UTF-8")));
EVERYWHERE I look, ppl are using these codes! But it doesn't work, some characters (such as the Euro sign) are displayed as squares.The problem isn't with the code, it's that the file you're reading isn't using an encoding that's compatible with UTF-8. Assuming that using UTF-8 should work for all encodings is like assuming that someone who can read Chinese should be able to read a book written in Spanish or Greek. It doesn't work that way.
However, I want to be able to read not only UTF-8 files but anything that Java supports. Any ideas?You need to know what encoding your files are stored in, period. There are a few ways to guess what the encoding is, but they're only reliable for a small set of encodings.
You don't seem to truly understand what character encodings are, or how to use them, so read this:
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
http://www.joelonsoftware.com/articles/Unicode.html -
How to read text file line by line...?
how to read text file line by line, but the linefeed is defined by user, return list of string, each line of file is a item of list?
please help me.
Thanks very muchBrynjar wrote:
In Groovy, you would do something like:
linefeed = "\n" //or "\r\n" if the user chose so
lines = new File('pathtofile').text.split("${linefeed}")This is one of the things that has always annoyed me about Sun's sdk, i.e. the lack of easy ways to do things like that. You always end up making your own utilities or use something like Apache's commons.io. Same goes for jdbc and xml - I'll wait for appropriate topics to show how easy that is in Groovy :)I generally agree, but what I really don't like about the Groovy text-file handling niceties: They don't care about encoding/always use the default encoding. And as soon as you want to specify the encoding, it gets a lot more complex (granted, it's still easier than in Java). -
Problem in reading Text file(Unicode)
Hi
i am trying to read a tab delimited text file which has Unicode Encoding
try{
BufferedReader reader = new BufferedReader(
new InputStreamReader(
new FileInputStream(
"C:/Documents and Settings/divya.parkash/Desktop/Testting.txt"),
"UTF8"));
int buf;
while((buf=reader.read())>-1){
if (buf!=0)
str.append((char)buf);
System.out.println(str.toString());
catch (Exception e){System.out.println("Res: "+e);}
}but i am geting two ?? marks before the text
??STD_BIN HI 0 100 U10 21010100 66.550 20.000 1.000 1.200 1.200 1.300 0 100 RACKED 0 0
STD_BIN LO 21010200 100 U10 21010200 66.550 20.000 3.000 1.200 1.200 1.300 0 100 RACKED 0 0
STD_BIN LO 21010300 100 U10 21010300 66.550 20.000 5.000 1.200 1.200 1.300 0 100 RACKED 0 0
STD_BIN LO 21010400 100 U10 21010400 66.550 20.000 7.000 1.200 1.200 1.300 0 100 RACKED 0 0
STD_BIN LO 21010500 100 U10 21010500 66.550 20.000 9.000 1.200 1.200 1.300 0 0 RACKED 0 0
STD_BIN LO 21010600 100 U10 21010600 66.550 20.000 11.000 1.200 1.200 1.300 0 0 RACKED 0 0So please suggest me the reason and solutionHi
calvino_ind
this is the output i am getting by keeping buf as int.......
553365533838468956673789727394899494848985494895049484948494848932323232323254544653534893232323232325048464848489323232323232324946484848999932323232323232494650484893232323232323249465048489323232323232324946514848948932494848982656775696894894813108384689566737897679950494849485048489949484898549489504948494850484893232323232325454465353489323232323232504846484848932323232323232514648484899993232323232323249465048489323232323232324946504848932323232323232494651484894893249484898265677569689489481310838468956673789767995049484948514848994948489854948950494849485148489323232323232545446535348932323232323250484648484893232323232323253464848489999323232323232324946504848932323232323232494650484893232323232323249465148489489324948489826567756968948948131083846895667378976799504948494852484899494848985494895049484948524848932323232323254544653534893232323232325048464848489323232323232325546484848999932323232323232494650484893232323232323249465048489323232323232324946514848948932494848982656775696894894813108384689566737897679950494849485348489949484898549489504948494853484893232323232325454465353489323232323232504846484848932323232323232574648484899993232323232323249465048489323232323232324946504848932323232323232494651484894893232324898265677569689489481310838468956673789767995049484948544848994948489854948950494849485448489323232323232545446535348932323232323250484648484893232323232324949464848489999323232323232324946504848932323232323232494650484893232323232323249465148489489323232489826567756968948948131083846895667378976799504948494855484899494848985494895049484948554848932323232323254544653534893232323232325048464848489323232323232495146484848999932323232323232494650484893232323232323249465048489323232323232324946514848948932323248982656775696894894813108384689566737897679950494849485648489949484898549489504948494856484893232323232325454465353489323232323232504846484848932323232323249534648484899993232323232323249465048489323232323232324946504848932323232323232494651484894893232324898265677569689489481310 -
Browser can't find a text file opened via the save as dialogue box
Hi there,
I have a servlet which outputs a file using the servlet output stream, with the following lines set:
response.setContentType("application/msword");
response.setHeader("Content-Disposition", "attachement; filename="+ fileName);
servletOutStream.write(myBytes);
servletOutStream.flush();
It works fine for .doc files and it seems the mechanism is that it is saved to the Temporary Internet Folder and delivered from there when the user clicks on the 'open' or 'save' option in the browser popup dialogue box. However... when I try this with text files, (setting the content type to "text/plain") I get the open/save dialogue box up correctly but if I try to open the file it says it cannot find the file, and gives the path under the Temporary Interenet Folder. If I look in there the text file isn't present - though the .doc files are.
So... it looks as if the problem is that for some reason it doesn't save the text files correctly to the Temporary Internet Folder.
I can't deliver the text files inline as a solution as the filename is lost and it thinks it's an html file (which the client doesn't want).
Any ideas?
AlisonAt least also set the content length. Your browser may be configured be the default application to open textfiles. If the contentlength is not set, then most applications would refuse to open the file without choosing for 'Save' first and manually open it.
Maybe you are looking for
-
Unable to delete Address Book File
I am unable to delete nor copy over an Address Book file that I have on an external HD connected via Airport Extreme. When I connect the HD directly to my Macbook Pro, I am able to delete the file - but not via Airport Extreme. When I attempt to dele
-
How do I transfer non-iTunes music files from my iPad to my MacBook using home sharing?
My MacBook Pro hard drive recently had to be replaced by Apple, because it quit for some reason they couldn't identify. However, now my ipad2 doesn't recognize my macbook pro and I have at least 200 music files in my library on my iPad that I did not
-
Hi guys, we have batch managementt only for FG items . But for raw materials, we are not follwing any batch management. But while taking the MIGO of raw materials by 101 movemnt type in plant: jainpur , the sytem is asking me to enter the production
-
Hello, how do I focus on a small section of screen using a circle with everything else blurred for a presintation? Thank you
-
Getting Music off of Ipod Touch
My computer crashed and the hard drive had to be replaced. I foolishly didn't have any of my music backed up. I have all my music and movies still on my Ipod Touch. Is there any way I can get my music off my Ipod, and onto a external drive, so that w