Help reading file
I put my DES key in a text file and stored within one of the java source folder like com.xyz.order.file.key
how do I read this file? It's saved in local hard drive. Thanks.
Either the path is wrong or the desired resource is actually not in the classpath.
That said, why are you reading it into a fixed length byte array? Is that file always 16 bytes long?
Still, the aforementioned IO tutorial is really worth reading. For sure in your case. Go read it.
Similar Messages
-
Need help reading file directory from applet!
Hi i am writing a java applet which has to read in several text files from its codebase directory. I have this code at the moment which causes a nullpointerexception:
public void initTables()
File dir = new File(getCodeBase().getPath());
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++)//null pointer here
String fileName = files.getName();
if(fileName.endsWith("set.txt"))
fileName = fileName.substring(0, (fileName.length() - 4));
Table t = new Table(this, fileName);
}Anybody know whats going on here?
thanksSorry i thought it was a null pointer, it's actually this:
java.security.AccessControlException: access denied (java.io.FilePermission C:\Users\Emud\Documents\pokemon read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.list(Unknown Source)
at java.io.File.listFiles(Unknown Source)
at Gui.initTables(Gui.java:75)
at Gui.init(Gui.java:16)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied (java.io.FilePermission C:\Users\Emud\Documents\pokemon read)
yeah, i'm making a program about pokemon...cos i'm cool 8) -
Need help reading files from a simple applet
hi everyone,
i have the following problem while trying to read from a file:
java.security.AccessControlException: access denied (java.io.FilePermission dr.xml read)
this problem shows up only when loading applet from a browser... if i use appletviewer everithing is ok.
this is the code:
cycle = new String[2];
phase = new String[8];
v = new Vector();
int temp;
try {
try {
fis = new FileInputStream("dr.xml");
while ((temp = fis.read()) > 0) {
buf += (char) temp;
fis.close();
fis = null;
} catch (java.io.FileNotFoundException ex) {
System.out.println("File does not exist. ");
} catch (java.io.IOException ex) {
System.out.println("error. ");
ex.printStackTrace();
}thanksYou don't have access to the file system. Think about it, you visit a web page and an applet starts reading your files? That's a HUGE security risk.
That said, I think you can do this if you have a signed/trusted applet. Google "signed applets" and "certificates" -
Hi,
I have a file with these contents
�One�
Hello Man. h
�Two�
This is the body of the message, which can go on for as long as possible.
which can go on for as long as possible. This is the body of the message, which can go on for as long as possible. This is the body of the message, which can go on for as long as possible.
MessengerI am using this code to read the contents of the file
try
DataInputStream msgFile = new DataInputStream(new FileInputStream(fileName));
String str = "";
while((str=msgFile.readLine())!= null)
if(str.equalsIgnoreCase("�One�") )
String one = msgFile.readLine().trim();
if(str.equalsIgnoreCase("�To�") )
String two = msgFile.readLine().trim();
} When I try to print String "two", I get only
This is the body of the message, which can go on for as long as possible. as I am using readLine() method
Is there a way I can solve this problem to read until the end of the file?
Mathewtry something like this
BufferedReader in = new BufferedReader(new FileReader(fileName));
data = in.readLine();
while (data != null) {
// Here is your line, do what ever you want to do
data = in.readLine();
} -
Hi, could any one give me some tips on how to fill this array from a file (data.txt) on the computer that reads:
50 99 44 35 37 22 12 19 7 44
77 64 23 52 59 62 85 98 5 100
72 70 60 50 43 30 20 10 91 1
11 31 81 98 61 13 21 25 44 10
The values are 1-100 but the program's array should have 10 spots. This is what I have so far but I'm confused about what I'm doing:
public static void main(String[] args)
EasyReader console = new EasyReader();
final int MAX = 100;
int [] values = new int [MAX];
int [] numberValues = new int [10];
// EasyReader File23 = new EasyReader("D:\\data.txt");
// String value= File23.readLine();
//System.out.print(value);
int logicalLength;
logicalLength = fillArray(numberValues);
System.out.print(logicalLength);
public static int fillArray(int []numberValues)
EasyReader File23 = new EasyReader("D:\\data.txt");
int LL = 0;
int xy= File23.readInt();
while (!File23.eof())
numberValues[LL] = xy;
LL++;
xy = File23.readInt();
File23.close();
return LL;
}thanks for the tip:
Any tips on how to fill this array from a file (data.txt) on the computer that reads:
50 99 44 35 37 22 12 19 7 44
77 64 23 52 59 62 85 98 5 100
72 70 60 50 43 30 20 10 91 1
11 31 81 98 61 13 21 25 44 10
The values are 1-100 but the program's array should have 10 spots. This is what I have so far but I'm confused about what I'm doing (there is an exception in the main too):
public static void main(String[] args)
EasyReader console = new EasyReader();
final int MAX = 100;
int [] values = new int [MAX];
int [] numberValues = new int [10];
int logicalLength;
logicalLength = fillArray(numberValues);
System.out.print(logicalLength);
public static int fillArray(int []numberValues)
EasyReader File23 = new EasyReader("D:\\data.txt");
int LL = 0;
int xy= File23.readInt();
while (!File23.eof())
numberValues[LL] = xy;
LL++;
xy = File23.readInt();
File23.close();
return LL;
} -
Help: The file "iTunes Library.itl" cannot be read because it was created by a newer version of iTunes
See Empty/corrupt iTunes library after upgrade/crash.
tt2 -
Reading files from within helper classes
From within a servlet, I can get the servlet context to get a path to the "web" directory of my project and easily access properties files for my project. If I create another package in my project to hold helper classes that perform some specific function and want to create and/or read from a properties file, I get a path to the bin directory of my servlet container:
Servlet Path: D:\Documents and Settings\Josh\My Documents\Josh\Projects\ServletSandBox\build\web\
Helper Class File Path: D:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\test
I'd like to develop my helper packages as reusable APIs, so they're not tied directly to my project or to a servlet in general, but I'd like the properties files to stay somewhere in my project folder, preferably in the WEB-INF directory with the servlet's own specific properties file.
I can't figure out the best way to handle this. I wanted to just be able to pass the helper class a String if somebody wanted to specify a filename other than the default filename. Does it make sense to specify a file URL instead? Is there any other way to get the calling servlet's context path without having to pass in a variable?
ThanksIt seems that the helper API shouldn't need to be given a path to its own config file. I would like to have code that will load the file regardless of whether or not its in a stand alone java app or a servlet. Whenever the helper API is jarred up and imported into my servlet, it can't find the config file unless it's in the "D:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\test" directory. OR, if I use the current thread to get the loader, it will locate it in the "classes" folder, which is the only solution I can come up with that will let me write code to load the file that will work, regardless of its implementation.
The "project" folder I'm talking about is just the NetBeans "project" folder for the servlet, or the "ServetSandBox" folder in my example. I guess that doesn't really matter in the context of the servlet though.
So is using the current thread the appropriate way to do this? When you say that code will work if I put the resource in the WEB-INF directory, that seems to only be true if I try to load it from the servlet itself, not the helper class. The helper class doesn't find the resource in the WEB-INF directory.
Also, I would like to be able to write the default values to a new config file if one doesn't exist. How in the heck do I get a pointer to the "classes" folder, or any other folder that I can also read from using the classloader, so I can write to a new file? -
Need help in reading file, got stuck
The code below works sometimes sometimes gives a message problem finding/reading file
public void readData()
try
DataInputStream dataIn = new DataInputStream(new FileInputStream("c://suneetha//data.txt"));
for(i=0;i<3;i++)
for(j=0;j<3;j++)
goal[j] = (dataIn.readInt());
dataIn.close();
catch (IOException e){ System.out.println("problem finding/reading file");}
catch (NumberFormatException nfe) { System.out.println("problem with format"); }
public void writeData()
int i=0,j=0;
InputStreamReader is = new InputStreamReader( System.in );
// Wrap input with a BufferReader to get
// the readln() method to read a whole line at once.
BufferedReader br = new BufferedReader( is );
try {
DataOutputStream dataOut = new DataOutputStream(new FileOutputStream("c://suneetha//data.txt"));
System.out.println("enter the array:");
String s = br.readLine(); // Read the whole line
st = new StringTokenizer(s);
// With tokenizer nextToken() method we can ignore
// any beginning and trailing white space.
for(j=0;j<9;j++)
i=Integer.parseInt(st.nextToken());//Convert string to int
System.out.println( "got: " + i );
j=i;
dataOut.writeInt(j);
catch (IOException ioe) {
System.out.println( "IO error:" + ioe );
not knowing what the problem is!!!
some times it accepts data from file(for reading) some times it wont.
I don't thing there is any problem with writing to the file
Any help is greatly appreciated
Thanks
Suneetha.Are you not posting this for third time ( and with same problems.)
Anyways.....
for(i=0;i<3;i++)
for(j=0;j<3;j++)
goal[j] = (dataIn.readInt()); // ????You want them in a 2 d array ?then make goal
int [][] goal = new int[3][3];
And
// use
if( dataIn.available() > 0 ){
goal[ i ][j] = dataIn.readInt();
else{
// Your "custom" messages
} -
Need help reading a file ~!
Hi,
I cant seem to read this file. It compiles without errors, but i get a java.nullPointerException when i run it. My data file looks like this:
5
class1
class2
class3
class4
class5
1-2 1-3 2-4 3-4 4-5
here is my code to read the file: public void Read(String fileName) {
try {
String num; //number of cells
String cells; //cell data
FileReader file = new FileReader(fileName);
BufferedReader in = new BufferedReader (file);
num = in.readLine();
number = Integer.valueOf(num).intValue(); //converts string to int
co = new ClassObject[number];
System.out.println("There are " + number + " total classes");
//## PROBLEM OCCURS IN THIS FOR LOOP which reads in the 5 names of classes
for (int b=0; b<number; b++){
co.className = in.readLine();
} //#### end of problem
while ((cells = in.readLine()) != null) {
StringTokenizer st1 = new StringTokenizer(cells, " ");
while (st1.hasMoreTokens()) {
String ST1 = st1.nextToken();
StringTokenizer st2 = new StringTokenizer(ST1, "-");
String ST2 = st2.nextToken();
co[x] = new ClassObject();
co[x].classNumber = Integer.valueOf(ST2).intValue();
ST2 = st2.nextToken();
co[x].classRelation = Integer.valueOf(ST2).intValue();
x++;
} catch (IOException e) {
System.out.println("Warning: Cannot Read File");
System.exit(0);
setPositions();
thanks for any help!Sorry, I didn't notice your comment in the code.
for (int b=0; b<number; b++){
co[ b]= new ClassObject();
co[ b].className = in.readLine();
} -
Reading file from an external folder.
Iam tring to read an external file from the C:\ drive. Given below is the code.
DATA LV_XLS(100) TYPE C.
DATA LV_CONTENT TYPE XSTRING.
LV_XLS = 'C:\XML\Report.xls'
READ DATASET LV_XLS INTO LV_CONTENT.
But when i execute iam getting an error - FILE NOT FOUND. How do i read file from an external folder. My requirement is to strictly read from an external folder. Please help.
If this is not possible please advice as to how the file could be moved to the SAP root directory. Iam not able to locate the root.hi,
This is the code to read a excel file from the local system.
Read data set you are using in your code corresponds to files on application server thats the reason its throwing an error.
* Parameter variable declaration for browsing the file location *
PARAMETERS:
p_file TYPE ibipparms-path OBLIGATORY.
data:
it_text TYPE truxs_t_text_data .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
* DYNPRO_NUMBER = SYST-DYNNR
field_name = ' '
IMPORTING
file_name = p_file.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_tab_raw_data = it_text
i_filename = p_file
TABLES
i_tab_converted_data = t_cust
EXCEPTIONS
conversion_failed = 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.
This is to read a text file from local system.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\FILEINTERFACE\file.TXT'
* FILETYPE = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_kna1
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* NO_AUTHORITY = 6
* UNKNOWN_ERROR = 7
* BAD_DATA_FORMAT = 8
* HEADER_NOT_ALLOWED = 9
* SEPARATOR_NOT_ALLOWED = 10
* HEADER_TOO_LONG = 11
* UNKNOWN_DP_ERROR = 12
* ACCESS_DENIED = 13
* DP_OUT_OF_MEMORY = 14
* DISK_FULL = 15
* DP_TIMEOUT = 16
* OTHERS = 17
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PS. In both of the above mentioned function modules make sure that the file structure is similar to the internal tables used.
Thanks
Sharath -
Unable to read file from application server
Hi guys,
I am reading file(could be any extension) from application server,but some time i am successfuly able to read file and sometime unable to read,why its happening .
my code is here
OPEN DATASET E_FILE FOR INPUT IN BINARY MODE . "
IF SY-SUBRC = 0.
DO .
READ DATASET E_FILE INTO GS_PDF_TAB.
IF SY-SUBRC = 0.
APPEND GS_PDF_TAB TO GT_PDF_TAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET E_FILE.
ENDIF.
Thanks
Ankur SharmaHi,
What actually happens? Do you get a short dump? Do you get a return code ne 0? Does it run fine but you get no data in your table?
We aren't mind-readers and can't help much without more information.
Try using transaction AL11 to see if you access the files you are trying to open.
Gareth. -
Uploading and reading file from application server
Hi
My problem is when am uploading a file to application server it is getting stored in
usr/sap/transyp1/prod/in directory
after that i want to read that file from application server to update database
when using below code it is showing some other directory in f4 help
DATA: lv_hostname TYPE msxxlist-name.
DATA: lv_server TYPE bank_dte_jc_servername.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'BANK_API_SYS_GET_CURR_SERVER'
IMPORTING
e_server = lv_server.
lv_hostname = lv_server.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-cprog
dynumb = '1000'
filetype = 'P'
location = 'A'
server = lv_hostname.
experts could you please help me out
Thanks & Regards
Nagesh.ParuchuriUser Transaction file. You will get all logical file path names.
used following fucntion module to read file name and use command open dataset to read the file.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = C_LOGICAL_FILENAME
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = P_IN_FILENAME
IMPORTING
FILE_NAME = P_OUT_FILENAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
OPEN DATASET P_OPEN_FILE ENCODING UTF-8 IN TEXT MODE FOR OUTPUT.
IF SY-SUBRC <> 0.
MESSAGE E000(38) WITH 'Error in Opening file: ' V_PHY_FILENAME.
ENDIF. -
Open Data Set Error while trying to read file from non SAP server
Hi all,
is it possible to read data from non-SAP application Sever?
I'm using OPEN DATASET p_filin FOR INPUT IN LEGACY TEXT MODE CODE PAGE '1504',
Where p_filin is other Windows server.Our applicition server is under Unix.Is it a problem?
I make test to read file from SAP application server and it was ok.So how to call other server?
Thanks!Hi,
Yes it is possible to read data from a non SAP server through the statement OPEN DATASET.
The important thing to check is that the SAP Server got enough access to the non SAP server so it can perform a reading/writing process depending on your needs.
You should contact your network administrator and BASIS to help you check the permissions. This can be pretty tricky, specially if the servers are in different domains.
Regards,
Gilberto Li -
Hi! I went to update my website, which I do every night before the first day of every month and all the files had a FIrefox icon instead of the usual Dreamweaver one. I have shut down, reinstalled DW MX 2004 but the files still do not open. The icons have now changed to DW but they are not opening with right click, opening from Applications folder, double clicking the file, from get info and open with DW. I am stumped. HELP! Need to update for March 1st.
Is it something to do with Leap Year 29th Feb? Checked the clock in preferences but can't see how this affects it.
Firefox is always updated but the latest version does not seem to be as efficient as previous upgrades. We installed Chrome as well. Do they interfere with each other?Hi Ken
I wish the 7.1 updater download had helped but it didn¹t. All the files
were backed up before the installation, which went fine.
Mac 10.5.8
We used Disc Warrior to defrag the hard drive, which did not make a
difference.
We recently started using Chrome, so now have 3 browsers in the dock,
Safari, Firefox and Chrome. Do they interfere in any way with each other?
The files, which I hadn¹t touched for a month as I update on a monthly
basis, initially had the Firefox icon.
Below is the message to send to Apple, which did not go through their report
system! A little disillusioned with the service!
Model: iMac9,1, BootROM IM91.008D.B08, 2 processors, Intel Core 2 Duo, 3.06
GHz, 4 GB
Graphics: kHW_NVidiaGeForceGT130Item, NVIDIA GeForce GT 130,
spdisplays_pcie_device, 512 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8E),
Broadcom BCM43xx 1.0 (5.10.91.22)
Bluetooth: Version 2.1.9f10, 2 service, 0 devices, 1 incoming serial ports
Network Service: Ethernet, Ethernet, en0
Network Service: AirPort, AirPort, en1
Serial ATA Device: WDC WD1001FALS-40K1B0, 931.51 GB
Serial ATA Device: PIONEER DVD-RW DVRTS08
USB Device: Built-in iSight, (null) mA
USB Device: Keyboard Hub, (null) mA
USB Device: iLok, (null) mA
USB Device: Apple Optical USB Mouse, (null) mA
USB Device: Apple Keyboard, (null) mA
USB Device: Deskjet 3840, (null) mA
USB Device: BRCM2046 Hub, (null) mA
USB Device: Bluetooth USB Host Controller, (null) mA
USB Device: IR Receiver, (null) mA
FireWire Device: d2 quadra (button), LaCie, 800mbit_speed
Does not mean a thing to me.
I am not late with updating the site, which is about New Zealand culture,
month by month (www.englishteacher.co.nz). Probably only the third time I
have been late since 2005. Not a huge amount of traffic, ~300 a month and
free access to content but I would like to solve this problem.
Could a reciprocal link have caused a problem?
At my wits end.
I really appreciate the help though.
Cheers Yvonne
From: Ken Binney <[email protected]>
Reply-To: <[email protected]>
Date: Wed, 29 Feb 2012 06:42:11 -0700
To: Yvonne and Bill Hynson <[email protected]>
Subject: HELP! Files won't open and previously had Firefox
icon instead of DW icons! Leap Year thing?
Re: HELP! Files won't open and previously had Firefox icon instead of DW
icons! Leap Year thing?
created by Ken Binney <http://forums.adobe.com/people/Ken+Binney> in
Dreamweaver - View the full discussion
<http://forums.adobe.com/message/4236682#4236682>
Not necessarily related, but did you also install the 7.1
updater? http://www.adobe.com/support/dreamweaver/downloads_updaters.html
Windows or MAC?
Replies to this message go to everyone subscribed to this thread, not
directly to the person who posted the message. To post a reply, either reply
to this email or visit the message page:
http://forums.adobe.com/message/4236682#4236682 To unsubscribe from this
thread, please visit the message page at
http://forums.adobe.com/message/4236682#4236682. In the Actions box on the
right, click the Stop Email Notifications link. Start a new discussion in
Dreamweaver by email
<mailto:[email protected].ad
obe.com> or at Adobe Forums
<http://forums.adobe.com/choose-container!input.jspa?contentType=1&container
Type=14&container=2240> For more information about maintaining your forum
email notifications please go to
http://forums.adobe.com/message/2936746#2936746. -
How to combine both DAQ AI signal, write and read file in single VI
Hi
I am the new user of LabVIEW version 7.1 for testing automation application. I have to measure 33 signals ( mostly analog like temp, pressure, etc...) from NI USB 6210 DAQ system and write in master file for future verfication.From real data or from master file back up have to write one more file if only the signal reaches steady state , which will used for analysis and same signals to be read from this file parallely & make a waveform and/or table display format.
Pl. help me to shortout this problem
note: I have plan to ugrade labVIEW version 2011 shortly, so let me know doing parrel acquistion write and read file for data analysis in same VI in version 7.1......Parallel operations in LabVIEW are very simple. Just code it in parallel and it will work.
Try taking a look at some of the examples in the NI Example Finder (Help > Find Examples). There you will find example for writing to and reading from files, as well as data acquistion in parallel with other operations.
You might need a producer/consumer architecture is you are acquiring data very quickly.
Chris
Certified LabVIEW Architect
Certified TestStand Architect
Maybe you are looking for
-
Can you purchase from the app store with someone else's appleid?
My grandson has his own iPhone. He uses it to play APPS. He has his own AppleID. His father downloaded a new game using his own AppleID onto his son's iPhone. My grandson's iPhone now seems to be confused as to what AppleID it belongs to? When an A
-
Error in file to idoc scenerio
hi in file to idoc scenario i got error in sxmb_moni in status it is showing recording, in Q.status it is showing stop symbol. waiting for suggestions.
-
Trouble opening project from Adobe Premiere Production Studio 2.0 in CS 5.5
Have almost finished editing a project in Adobe Premiere Pro 2.0 when computer died - have upgraded computer and software to cs 5.5 and told over phone by Adobe that will be able to open current file saved in 2.0 in CS 5.5. no problems.... BUT...it's
-
Hi Experts, We are using a custom webdynpro application for the approval of expense claim.If I am clicking the link from UWL, a new window is opened and it is showing a blank page and PDF is not displaying in the browser. I have checked from applicat
-
I'm planning to buy the new iPod touch. What's the quickest way to get it, pre ordering it, or buying it in-store when it comes out?