How to read contents of the Super Block ext2
there I'm working on traversing an ext2 filesystem to read from it and I'm stumped at the first hurdle. The filesystem has a block size of 1024 bytes, so I need to read from the first 1024 bytes into an array to get Block Group 0. From there I need to go to the position of the super block, but I don't know how to go through the following first steps:
1 Find the Group Descriptor 2 Read the Inode Table Pointer value to find the block containing the first inode 3 Read Inode 2 (the root directory/ top of the filesystem) -- the length of each inode is given in the Group Descriptor 4 Traverse the filesystem as shown above to locate the file and its contents/ data blocks
I have some code below that reads the file in one go.
try { aFile = new RandomAccessFile("ext2fs", "r"); FileChannel fileChannel = aFile.getChannel(); long fsize = fileChannel.size(); ByteBuffer buff=ByteBuffer.allocate(1024); fileChannel.read(buff,1024L); buff.flip(); byte[] data = buff.array(); System.out.format("%s\n", new String(data)); buff.clear(); fileChannel.close(); aFile.close(); } catch (IOException e) { System.out.println("File not found"); } here
Thanks
The best solution is that you redesign your program so that it does not depend on the order of the entries in the properties file.
If you really want to stay with your design, you will have to read the properties file yourself, line by line, just like you would read any other text file, and parse the content of each line yourself.
BufferedReader in = new BufferedReader(new FileReader("stuff.properties"));
String line;
while ((line = in.readLine()) != null) {
// Parse the line, use e.g. String.split() to split it around the '='
in.close();
Similar Messages
-
How to read contents of more than 2 files.
hi all
help me.
How to read contents of more than 2 files.
For reading a file contents we uses normally FileInputStream
For reading two file contents we uses normally SequenceInputStream
But which class we have to use for reading contents of more than 2 files at a time
thanks in advance.SequenceInputStream can be used for reading any number of input streams (not at once, but one after the other).
This involves making an Enumeration that returns the input streams you want to read. Depending on what you want to do, it might be just as easy to read them one after another.
Or consider making a Vector of your input streams and using its elements() method. Like this:(untested)Vector<InputStream> inVec = new Vector<InputStream>();
inVec.add(new FileInputStream("foo.dat"));
inVec.add(new FileInputStream("bar.dat"));
inVec.add(new FileInputStream("baz.dat"));
// later...
SequenceInputStream in = new SequenceInputStream(inVec.elements()); -
How to read contents of a property file sequentially
hello all,
please can any one tell me how to read contents of a property file sequentially.
i saw most of the classes provided by JAVA API, which get All keys and there return type is enumeration which dosent preserve , or may the getKeys() method of those classes do not preserve the sequential order.
Kindly do let me know if anyone has done this before.
Thanks.The best solution is that you redesign your program so that it does not depend on the order of the entries in the properties file.
If you really want to stay with your design, you will have to read the properties file yourself, line by line, just like you would read any other text file, and parse the content of each line yourself.
BufferedReader in = new BufferedReader(new FileReader("stuff.properties"));
String line;
while ((line = in.readLine()) != null) {
// Parse the line, use e.g. String.split() to split it around the '='
in.close(); -
How to read and update the value of property file
Hi,
I am not able read the values from property file.
Please tell me how to read and update the values from property file using Properties class
This is my property file : - Config.properties its located in D:\newfolder
Values
SMTP = localhost
Now i need to change the value of the SMTP
New value :
SMTP =10.60.1.9
Pls Help me
Thanks
Merlin Rosina,Post a small (<1 page) example program that forum members can copy and run that demonstrates your problem.
-
I plugged in my ipod to install the latest version of itunes on my computer and I got this message: "itunes cannot read contents of the ipod. go to summary tab in ipod preferences and click restore to restore to factory settings". I can't get rid of it and now have zero songs on my ipod but all of my songs are in my library. Help, please.
Sorry, my mistake, the nano has a flash-based drive so most of that post won't apply, although you might see if the DFU restore section works.
Try also suggestions from iPod nano: Error message saying that iPod 'could not be identified properly'
tt2 -
How to read or change the planning book in APO ???
Hi all ,
can anybody tell me how to read or change the planning book in APO
Regards,
Tarang ShahHi ,
you can use the follwing BAPI
BAPI_PBVARS_GETDETAIL to read the planning book
BAPI_PBVARS_CHANGE_KEY* to change the planing book
thanks and regards ,
Ashok kumar -
How to write content of the file under folder
Hi Experts,
I have following scenario, I have list of files under folder in local desktop(for eg D:\mani)
I have only filename, using this filename i want to search and get content of the particular file and write in some other location? how to do that? give your suggestions?
Regards,
P.ManivannanYou could go two ways here:
The first possibility requires that (a) you know what operating system you are working with, and (b) you only need to copy the file, and not do anything else with the contents of it. In this case, probably the easiest way to do this is to use a Runtime exec command for the file you want to copy:
java.lang.Runtime.getRuntime().exec( "cp D:\mani D:\mani2" );Otherwise, if you need your code to be portable, you can't assume anything about the operating system. Since java.io.File doesn't provide a copy method, you will need to read the entire contents of the file into the vm, and then write them out to a new file. Also, if you need to use the contents of your file in some other way, as well, then you also need to read the entire contents into the vm. In this second case, how you read the file may depend on what kind of data the file contains.
In general, the following code should work for you:
final FileInputSteam fis = new FileInputStream ( new File( "D:\mani" ) );
final FileOutputStream fos = new FileOutputStream( new File( "D:\mani2" ) );
final byte [] buf = new byte[ 1024 ];
int bytesRead;
while ( ( bytesRead = fis.read( buf ) ) != 0 )
fos.write( buf, 0, bytesRead );Don't forget to catch or throw IOException.
Hope this helps.
- Adam -
How to read contents of files that do not fall under public security group?
Hi,
I need to read the contents of a WCM based xml file that does not fall under public security.
The process is like this:
First the user makes chnages to the content.
The workflow will be triggred based on the security group metadata that is associated with the content.
Once the content is finally approved our workflow calls a custom idoc script.
First we tried directly reading the xml contents from the idoc script which was still in the context of workflow. But since content item is still in workflow I was not able to read the changes. So I created a separate content publisher thread and read the DOC_INFO and checked for the dStatus value. If the value is RELEASED then I reading contents by calling ssIncludeXml idoc script.
This was working fine for public content. But now the requirement is that all content cannot be public. Content authors should not be able to edit the content that does not belong to their group, So we created security groups (and roles) and are associating that groups to the relavent content.
Beacuse of this change I am not not able to read the non public content. The call to DOC_INFO_BY_NAME service, which gives all the content files' metadata, is expecting the user to be logged in to give the details.
I tried calling the CHECKIN service with sysadmin and captured the cookies returned by that service and use cookies for the DOC_INFO_BY_NAME service call. But the service call was faling. It is throing the 401 forbidden error with the message that user needs to be logged in to get the details.
How to address this problem. Someone please help.
Note: I also tried using ridc for this. I was able to get it working but since it is executing in the context of server ridc api is changing server's environment properties like HTTP_HOST, HTTP_CGIPATHROOT etc. It also seemed like system was becoming non functional after using ridc. When I called check-in the system metadata values like security group are no more loading. Not sure if ridc is the culprit here but worried that it might be causing this issue.
Regards,
PratapSorry, I posted too much details while posting this question. I was saying "not able to read *non* public content".
Anyway, I was able to resolve the issue. I was able to authenticate with sysadmin credentials in the request to service using basic authentication and was able to read doc info with that credential.
But I realized there is more than option for reading secure content.
- I could set user name as sysadmin in the m_environment (if I am in the context of a service) and the call the DOC_INFO_BY_NAME service.
- I can post an HTTP request to DOC_INFO_BY_NAME service with sysadmin credentials and do basic authorization via the connection. (This is what i have done successfully as of now )
- I could add guest role to all security groups with R (read) privileges.
I will look into all options and implement the one which is more apt.
Regards,
Pratap -
How to read contents of an array into a variable?
Gurus,
I'm trying to read contents of a table or array into a varray variable. I want to know the syntax of how to accomplish the same. Please help
Here is what i have,
v_sub_query varray(10) of varchar2;
v_sub_query should read contents of an array and hold values. I'm trying to do this and then use each values of v_sub_query(index) into a dynamic sql statement.
thanks
SSSign is definately not king when it comes to PL/SQL as his advice is flawed. Row-by-row processing simply causes a lot of context switches from the PL/SQL engine to the SQL engine and back. And this results in a significant performance impact. Never mind that this style of 80's COBOL processing it sadly outdated in the 21st century when dealing with a modern RDBMS likle Oracle.
The correct way to populate an array in PL/SQL with SQL data, is to bulk collect it. However, a varray data type is not the best suited data type for this - as they are fixed sized. Dynamic arrays are more flexible.
Simple example:SQL> declare
2 type TStrings is table of varchar2(30);
3 cursor c is select object_name from all_objects order by 1;
4 v_NameTable TStrings;
5 begin
6 open c;
7 loop
8 fetch c bulk collect into v_NameTable limit 100; -- fetch 100 rows at a time
9 -- process the array
10 for i in 1..v_NameTable.Count
11 loop
12 -- process element v_NameTable(i)
13 null;
14 end loop;
15 exit when c%NOTFOUND;
16 end loop;
17 close c;
18* end;
SQL> /Refer to the Chapter 5. Using PL/SQL Collections and Records of the Oracle® Database PL/SQL User's Guide and Reference guide.
As for dynamic SQL - remember to use bind variables. Do not hardcode the array values into the SQL statement as the resulting SQL will not be sharable and will cause performance problems with SQL parsing and shared pool memory fragmentation and malloc errors. -
How to read contents of a spool?
hi
any fm to read the contents of the spool by giving a spool req. no? i want to know before processing a spool whether it has some contents or is null ('List contains no data')..how to know this? any help is appreciated
Regards,
Sathish. RHi,
You may need to first call function module RSPO_RINIT_SPOOL_SP01 which contains the statement ASSIGN DUMMY2 TO <FSPORQ>. Since RSPO_RINIT_SPOOL_SP01 is in the same function group as RSPO_ROUTPUT_JOB, the assignment will remain when you call RSPO_ROUTPUT_JOB.
See module pool RSPOSP01NR, form DISPLAY_OUTPUT_REQUESTS for an example of the use of RSPO_RINIT_SPOOL_SP01.
Check this <b>RSPO_RID_SPOOLREQ_DISP</b>
Regards -
Itunes cannot read contents if the ipod
when plugged in it has windows display a warning that reads "itunes cannot read he contents of the ipod, go to summary tab in ipod preference and click restore to restore to factory settings" i have tried the 4 r's but the 5th r i am unable to do unless itunes can read the ipod right?? how do i restore this thing (nano) if itunes wont read it and allow me to go to ipod preferences???
this happened to me...another way to restore the ipod is to open it in my computer and right click on the drive your ipod is in . then choose "format" in format press start and it will restore your ipod (meaning it will delete everything off of it) once this is done try to connect to itunes...if that does not work, right click on "my computer" click "manage" then select "services and applications", then "services", then select "IPOD service"...if its not already, connect your ipod. press "stop" then "start"....then try it again in itunes.
the end -
Dear All.
I have 2 application progrlams in the same block diagram. the intention is to use the 2 programs at different excuting time for different application, and each have stop and start button ofcourse i will have master stop. But when i run the program, it only works one program at time , that is the 1st block which i make it active only , when i tried to make active the second block it will not work, only works when i stoped the1st one. So, this it to request ur hlep how can i solve my problem. here i have attached some of my program.
Regards!
Solved!
Go to Solution.
Attachments:
2_block application.vi 14 KBUsually you set up a task that has all the channels from all the modules configured. When a loop starts it reserves that task and the cDAQ can't be used by other loops unless you start and stop tasks.
You can have one loop acquire all the data and if you want certain channels to go to other loops you can use the producer/consumer design pattern. If you wanted a third loop you would add another queue and the third loop would dequeue that data. See attached.
Eric
Attachments:
prod-cons.vi 69 KB -
How to read data from the data provider using javascript
Hi,
Please let me know how to read the data from the dataprovider using javascript(query assigned to the data provider).
My query has filter charateristics, free charateristics, charateristics in rows and key figure in column.
Thanks a lot for your kind help
Regards
KandasamyKandaswamy,
Assign an ID to your table item , then in JavaScript , you can use ID.innerHTML and you will get the HTML code within that table for the same , then you can find out how best to get the exact value you desire from the innerHTML value which is a string with the entire HTML from within the table item.
Arun
Hope it helps.... -
How to read and write the data like this(is JSON?)?
i have some data like below(is json?),how to write them into
the database?
i user coldfusion 7.
{"title":"ColdFusion?","url":"
http://www.adobe.com/cfusion/"},
{"title":"flex blogs","url":"
http://www.flexblogs.com/"},
{"title":"studio","url":"
http://www.sans.com.com/"}
Thank you very much!You need to parse it and then insert the records into your
database.
Take a look at
CFJSON it is a JSON
serialiser and de-serialiser.
Once you have converted it to native CF datatypes you can
loop through it and insert it into your database. -
How to read files outside the jar ?
Hi all,
One of my classes inside jar needs to read XML file that resides in the same location where the jar sits. I use MyClass.getClass().getResource("MyXMLFile.xml") but it keeps returning null.
If I place the XML file inside the JAR, I can find it using above methods, but since I want the user to easily edit the XML file without opening the jar file and detach the XML file, I choose not to include the XML file inside the jar.
Any help would be greatly appreciated.
SetyaThanks for the dukes.
My JDBC post on this forum discusses the issues of
using Class-Path in your jar file. It works, but it
may vary from system to system.
Thanks also from my side: I have read recently your discussion about reading files in the jar's directory, since I had the same problem. So I was really glad to see your solution. However, I had one more problem, namely that I'm running my application sometimes from the jar, sometimes from the classes directly (debugging). In order to have always the correct path (although a different one) I have added some more lines to deal with that case. I hope that will be useful for you as well!
Dieter Profos
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.net.URL;
* @author pkwooster
* @author Dieter Profos
* @version 1.01 04/03/26
public class ReadOutside extends Frame {
private TextArea textArea;
public static void main(String[] args) {
// Create application frame.
ReadOutside tc = new ReadOutside();
tc.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
// Show frame
tc.setSize(600,250);
tc.setVisible(true);
public ReadOutside() {
textArea = new TextArea(20,80);
add(textArea);
readOutside(this);
public void readOutside(Object o) {
System.out.println(getCodeBasePath(o));
/** Gets the absolute path of the directory where the JAR or CLASS file is
* located. If the application is run from a jar file, the directory of the
* jar file is returned; if it is run from a class file, the method will
* return the directory path of the class file.
* @param o The main class of the application.
* @return The absolute directory path, or null if neither the class nor a
* jar file could be found.
public String getCodeBasePath(Object o) {
Class c = o.getClass();
URL url;
// get the class name
String className = c.getName();
textArea.append("class name = " + className + "\n");
// replace package periods by file separators
className = className.replace('.','/');
ClassLoader cl = c.getClassLoader();
if (cl == null)
cl = ClassLoader.getSystemClassLoader();
url = cl.getResource(className + ".class");
String xPath = url.toExternalForm();
textArea.append("url = " + url + "\n");
textArea.append("extPath = " + xPath + "\n");
// make sure that the path starts with jar:file:
if (xPath.startsWith("jar:file:")) {
// remove jar:file: + the subsequent file separator
xPath = xPath.substring("jar:file:".length()+1);
int n = xPath.indexOf("!");
if (n < 0)
n = xPath.length();
String jarPath = xPath.substring(0, n);
textArea.append("jar file path = " + jarPath + "\n");
n = jarPath.lastIndexOf("/");
String jarDir = jarPath.substring(0, n+1);
textArea.append("jar dir = " + jarDir + "\n");
return jarDir;
else { // if program is run from its class file (development phase!)
if (xPath.startsWith("file:")) {
// remove file: + the subsequent file separator
xPath = xPath.substring("file:".length()+1);
textArea.append("class file path = " + xPath + "\n");
int n = xPath.lastIndexOf("/");
String classDir = xPath.substring(0, n+1);
textArea.append("class dir = " + classDir + "\n");
return classDir;
return null;
Maybe you are looking for
-
Windows freezes when I plug in iPod
My iPod was working fine until I updated my iTunes software yesterday (10.15.05). While updating my computer froze completely and I had to do a hard shut down. Now, when I plug in to the USB 2.0 port (which is Belkin pc card external - bought at an a
-
Displaying Graph and Charts in Portal
Hi Guys, I want to display the Graph and charts dynamically in percentage wise for example ,I need to get the data from the data base of student table on passing marks of each subject i want to display the graph or chart accoridng to his marks ,,, I
-
I replaced an HP J6400 printer with an HP 6700 premium printer. The installation was OK and the printer works fine. The HP solution center which worked very well with the 6400 printer does nor recognize the 6700 and when I removed ( uninstalled) the
-
it report "参数无效" or "无此权限", when i click on example in result I searched some class with blueprint in windowsXP and flash builder burrito,
-
Problem in integrating Dreamweaver MX with SAP xMII
hi all, i am using Dreamweaver MX and xMII 11.5 i have followed the steps for <a href="http://help.sap.com/saphelp_xmii115/helpdata/en/Getting_Started/InstallationGuide.htm#Installing_the_Dreamweaver_Add_in">Installing the Dreamweaver Add-in</a> <b>