I have a problem in substring

I want to read from a file.The file contain strings like
Cpu(s): 0.7% us, 0.7% sy, 0.0% ni, 98.3% id, 0.0% wa, 0.3% hi, 0.0% si
I want to take the value 0.7 from the file.
so I use substring(9,12) a pgm
import java.io.*;
class FileRead
public static void main(String args[])
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("C:\\abc.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine=null;
     //String ss;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println(strLine.sustring(9,12));
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
But it shows an error message
Error: String index out of range: 12
pls help me to solve this problem as soon as possible

Obviously a line you read from the file is less than 12 chars long. Try adding a print statement to print the entire string first so you can see what is being read from the file.

Similar Messages

  • Problem with substring in xsl file?

    Hallo,
    i have a xsl file, when using
    <xsl:value-of select="StsEdat"/> i've got 2007-05-21, that's o.k.
    when using <xsl:value-of select="substring(StsEdat,9,2)"/> the answer is blank.
    also 0,5 or so on. substring at this position delivers blank. why?
    what can it be? i'am helpless.
    any help is appreciated.

    Hi,
    I used <xsl:value-of select="substring(StartDate,9,2)"/> the answer was 21 and to 0,5 the answer was 2007. It seems that's ok!
    Try to do it and see if you have problem with substring.
    <xsl:variable name="StsEdat">2007-05-21</xsl:variable>
    <xsl:value-of select="substring($StsEdat,9,2)"/>
    or this weird way, :)
    <xsl:variable name="StsEdat">2007-05-21</xsl:variable>
    <xsl:value-of select='substring-after(substring-after($StsEdat, "-"), "-")' />
    Regards,
    Cleiton

  • ICC profile to convert RGB to CMYK,   jpeg is ok, png format have a problem

    When I use ICC profile to convert RGB to CMYK, jpeg format is ok, but png format have a problem.the color is lossy.
    It means, the png file color is shallow than jpeg file after convert.Could anybody help me?
    thanks
    source code
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.Iterator;
    import javax.imageio.IIOImage;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageTypeSpecifier;
    import javax.imageio.ImageWriteParam;
    import javax.imageio.ImageWriter;
    import javax.imageio.metadata.IIOMetadata;
    import javax.imageio.metadata.IIOMetadataNode;
    import javax.imageio.stream.ImageOutputStream;
    import org.w3c.dom.Node;
    import com.sun.image.codec.jpeg.ImageFormatException;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGEncodeParam;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    public class TestImage {
         public static void main(String args[]) throws ImageFormatException, IOException{
              BufferedImage readImage = null;
              try {
                  readImage = ImageIO.read(new File("C:\\TEST.jpg"));
              } catch (Exception e) {
                  e.printStackTrace();
                  readImage = null;
              readImage = CMYKProfile.getInstance().doChColor(readImage);
              writeImage(readImage, "C:\\TEST_after_.jpg", 1.0f);
        protected static String getSuffix(String filename) {
            int i = filename.lastIndexOf('.');
            if(i>0 && i<filename.length()-1) {
                return filename.substring(i+1).toLowerCase();
            return "";
        protected static void writeImage(BufferedImage image, String filename, float quality) {
            Iterator writers = ImageIO.getImageWritersBySuffix(getSuffix(filename));
            System.out.println("filename�F"+filename);
            if (writers.hasNext()) {
                ImageWriter writer = (ImageWriter)writers.next();
                try {
                    ImageOutputStream stream
                        = ImageIO.createImageOutputStream(new File(filename));
                    writer.setOutput(stream);
                    ImageWriteParam param = writer.getDefaultWriteParam();
                    if (param.canWriteCompressed()) {
                        param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);//NO COMPRESS
                        param.setCompressionQuality(quality);
                    } else {
                        System.out.println("Compression is not supported.");
                    IIOMetadata metadata = null;
                    if(getSuffix(filename).equals("png") || getSuffix(filename).equals("PNG")){
                         ImageTypeSpecifier imageTypeSpecifier = new ImageTypeSpecifier(image);
                         metadata = writer.getDefaultImageMetadata(imageTypeSpecifier, param);
                            String sFormat = "javax_imageio_png_1.0";
                            Node node = metadata.getAsTree(sFormat);
                            IIOMetadataNode gammaNode = new IIOMetadataNode("gAMA");
                            String sGamma = "55556";
                            gammaNode.setAttribute("value", sGamma);
                            node.appendChild(gammaNode);
                            metadata.setFromTree(sFormat, node);
                    writer.write(null, new IIOImage(image, null, metadata), param);
                    writer.dispose();
                    return;
                } catch (IOException ex) {
                    ex.printStackTrace();
    }

    Hi,
    I am having similar problems. I have read somewhere that png format can not handle CMYK colorspace anyway, which I find odd (and plainly stupid IM(NS)HO) which would mean that converting to RGB and therefore using profiles is mandatory.
    May be you should check if the internal format of the png files claims it is RGB or CMYK (using ImageMagick's "identify" command for example).
    HTH
    JG

  • Problem with SUBSTR

    En una view, al crear un campo con SUBSTR( campo, 1, 150), devuelve un campo con tamaño de 600, el correcto seria 150, cual es la causa ?

    Hi user 512674,
    Please, post your questions in English. Otherwise, only Spanish-speaking people can help you (or those who can guess what the problem is ;)
    SUBSTR(campo, 1, 150) means 150 characters. In an AL32UTF8 database, which you most probably have, this translates to 4*150=600 bytes. That is, the column must be able to store 600 bytes to be sure that it can store 150 AL32UTF8 character codes.
    View creation does not depend on the value of the session parameter NLS_LENGTH_SEMANTICS. The view columns inherit the semantics from the underlying table columns. If <campo> column is defined with character semantics the view column will be created with character semantics: ALL_TAB_COLUMNS.DATA_LENGTH will show 600 (bytes), ALL_TAB_COLUMNS.CHAR_LENGTH will show 150 (characters), ALL_TAB_COLUMNS.CHAR_USED will show 'C'. Otherwise, the view will be created with byte semantics: ALL_TAB_COLUMNS.DATA_LENGTH will show 600 (bytes), ALL_TAB_COLUMNS.CHAR_LENGTH will show 600 (characters), ALL_TAB_COLUMNS.CHAR_USED will show 'B'.
    -- Sergiusz

  • I have a problem with wifi in my iphone 4s, i already try everything and download latest version 7.1(11D167) but wifi switch is not working, its my humble request to Apple support team that pls resolve this problem as soon as possible because

    I have a problem with wifi in my iphone 4s, i already try everything and download latest version 7.1(11D167) but wifi switch is not working, its my humble request to Apple support team that pls resolve this problem as soon as possible because its a prestiage of Apple Company.
    Pls inform me how can i resolve the problem of wifi.

    You have to go to autherized iPhone agent.

  • Have a  problem with Lightroom 5.4.  Since the program crashed yesterday it won't launch, it comes up with the message "Lightroom encountered an error when reading its preview cache and needs to quit".  "  Lightroom will attempt to fix this problem net ti

    Have a  problem with Lightroom 5.4.  Since the program crashed yesterday it won't launch, it comes up with the message "Lightroom encountered an error when reading its preview cache and needs to quit".  "  Lightroom will attempt to fix this problem next time it launches".  Except that it doesn't, I keep getting the same message and the program closes.  Does anyone know what I  can do to repair it?  Can't back up, can't do anything.

    There are dozens of threads in this forum that describe the fix

  • Hello, I've updated the iPhone I have got I have a problem I hope you respond to some of the applications no longer work, such as the safari and skype and many applications are no longer working with the ios7.0.4

    Hello, I've updated the iPhone I have got I have a problem I hope you respond to some of the applications no longer work, such as the safari and skype and many applications are no longer working with the ios7.0.4

    Standard troubleshooting...
    1. Try a Restart by pressing the sleep/lock button until you see the slider.  Slide to power off.  Restart by pressing the sleep/lock button until you see the Apple logo.
    2. Try a Reset by pressing the home and sleep buttons until you see the Apple logo. Takes about 5-15 secs of button holding and you won't lose any data or settings.
    3. Remove apps from Recently Used (multi-tasking) list...
    - From any Home Screen, double tap the home button to bring up the Recents List
    - Swipe up on the app preview card to remove it from the list
    - Press the home button when done.
    4. If still a problem restore with your backup.
    5. If still a problem restore as new, i.e. without your backup. See how it runs with nothing synced to it.
    6. If still a problem, it's likely a hardware issue.

  • I have a problem with the sync between iTunes and ipad2. I can not see the files in iPad. Help me please.

    I have a problem with the sync between iTunes and ipad2. I can not see the files in iPad. Help me please.

    Cannot see what files ? Music (synced music should appear in the iPod app), films/TV shows (Videos app), documents ... ?

  • How do I stop Firefox from creating untitled web pages when I try to send email from a web page. The only way I have found is to turn the computor off and then reboot. I don't have this problem when using Internet Explorer

    Every time I click on a web site that has an email option the browser starts making untitled web pages and never stops unless I turn the computer off. It is very frustrating to not be able to use an email option when offered by a web site. The only way I can send email messages on the Firefox browser is to go into my hotmail acct. and copy and paste the addresses. I don't have this problem when I use the Internet Explorer browser.

    See [[Firefox keeps opening many tabs or windows]]

  • TS2446 i have a problem in my account every time i want to install application from app Store on my iphone a message shows that my Apple ID has been disabled, what is the problem? what can i do ?

    i have a problem in my account every time i want to install application from app Store on my iphone a message shows that my Apple ID has been disabled, i creat a new password and still that message shoes ,what is the problem ?can you help me please???!!!!

    If your account is disabled then you might be able to re-enable it via this page : http://appleid.apple.com, then 'reset your password'
    You might then need to log out of your account on your phone by tapping on your id in Settings > iTunes & App Store and then log back in so as to 'refresh' the account on it
    If that doesn't fix it then you might need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • I have a problem with JDBC Realm in Tomcat/Oracle/Win XP

    I have a problem with JDBC Realm in Tomcat.
    I have attached my server.xml file located in the
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
    The Problem is that when I login I get the user name and password prompt but it does not resolve.
    When I enter in the tomcat-users.xml password with memory realm uncommented it works fine.
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\tomcat-users.xml
    Is there a cache or something I need to reset for the JDBC Realm to work?
    I have attached my tables and contents as well...
    Did I miss something????
    Thanks
    Phil
    server.xml
    <Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
    <!-- Global JNDI resources -->
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    </GlobalNamingResources>
    <!-- Define the Tomcat Stand-Alone Service -->
    <Service name="Catalina">
    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector
    port="8080" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009"
    enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Catalina" defaultHost="localhost">
    <!--
    <Realm className="org.apache.catalina.realm.MemoryRealm" />
    -->
    <Realm className="org.apache.catalina.realm.JDBCRealm"
    driverName="oracle.jdbc.driver.OracleDriver"
    connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
    connectionName="testName" connectionPassword="testPass"
    userTable="users"
    userNameCol="user_name"
    userCredCol="user_pass"
    userRoleTable="user_roles"
    roleNameCol="role_name" />
    <!-- Define the default virtual host
    Note: XML Schema validation will not work with Xerces 2.2.
    -->
    <Host name="localhost" appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    </Host>
    </Engine>
    </Service>
    </Server>
    Tables
    create table users
    user_name varchar(15) not null primary key,
    user_pass varchar(15) not null
    create table roles
    role_name varchar(15) not null primary key
    create table user_roles
    user_name varchar(15) not null,
    role_name varchar(15) not null,
    primary key( user_name, role_name )
    select * from users;
    ----------------------+
    | user_name | user_pass |
    ----------------------+
    | tomcat | tomcat |
    | user1 | tomcat |
    | user2 | tomcat |
    | user3 | tomcat |
    ----------------------+
    select * from roles;
    | role_name |
    | tomcat |
    | role1 |
    select * from user_roles;
    -----------------------+
    | role_name | user_name |
    -----------------------+
    | tomcat | user1 |
    | role1 | user2 |
    | tomcat | tomcat |
    | role1 | tomcat |
    -----------------------+

    Jan 2, 2008 11:49:35 AM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Jan 2, 2008 11:49:35 AM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 734 ms
    Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
    Jan 2, 2008 11:49:35 AM org.apache.catalina.realm.JDBCRealm start
    SEVERE: Exception opening database connection
    java.sql.SQLException: oracle.jdbc.driver.OracleDriver
         at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:684)
         at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:758)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1004)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
         at org.apache.catalina.core.StandardService.start(StandardService.java:450)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
    Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    Jan 2, 2008 11:49:36 AM org.apache.catalina.core.StandardContext resourcesStart

  • Itunes wont sync songs to ipod - didnt have this problem when i had xp

    this is the message i get -
    Attempting to copy to the disk 'RYAN'S IPOD' failed. You do not have enough access privileges for this operation
    iTunes could not save to your Music Folder because you do not have write access. Check the permissions on your Music Folder and folders in your Music Folder, then try copying this file again.
    i keep getting this after i go and check the permissions and make sure everything is the way it should be... i didnt have this problem before upgrading to vista
    toshiba   Windows Vista  
    toshiba   Windows Vista  

    I'm not sure if this will do anything, but maybe you could find the iTunes Music folder, right click - properties, and unchecked read only if it's checked.

  • I cannot see my Hotmail saved messages on my iPad 4.  I do not have this problem on my iPad 2.  All settings look identical.

    I cannot see my Hotmail saved messages onmy iPad 4.  I do not have this problem on my iPad 2.  The settings appear identical.Any suggestions to cure the problem?  Thank you.

    My iPad 2 does exactly the same thing. But I just have to go on to my wifi options and you can either forget this network and then press it again or you can turn wifi off and on again and press that wifi.
    Kind regards,

  • TS3694 good evening i have an problem with my iphone 4 the wif and network cant on now if i tray is showing iTunes i tray to reload the ios is showing an error -1 can you help me

    good evening i have an problem with my iphone 4 the wif and network cant on now if i tray is showing iTunes i tray to reload the ios is showing an error -1 can you help me

    No problem, glad to help!
    Update: my PC USB hub was connected to a USB 3 port, I connected the 30 pin cable directly to my PC, And the restore worked just fine. Restored phone from iCloud backup and seems to be working fine.

  • Hello I have a problem since my installation of the Yosemite update on my Mac I can longer open Indesign CS6

    Hello
    Hello I have a problem since my installation of the Yosemite update on my Mac I can longer open Indesign CS6.
    I have a problem since my installation of the Yosemite update on my Mac I can more open Indesign yet I have installed JavaForOSX2014-001 but it has changed nothing someone could help me?

    Please do not post the same question multiple times. If someone can help you, they will, but you need to be patient -- we're all just volunteers, users like yourself. I'm going to delete your other posts.

Maybe you are looking for

  • Internal Table in VA02 Partners

    Hi Experts, Is there anyone knows what is/are the internal tables I need to modify in order to update the Partners in Item Data of the Regular Item and Free goods of  a certain order number for the transaction VA02? I tried to modify the internal tab

  • Which folder to put custom sso dlls in 6.1?

    Anyone know into which folder(s) to place custom sso dlls in G6/6.1?

  • SRM-SUS 7.0 - Updating Vendor Bank from BP Bank Details

    Hi SRM Gurus, We are implementing SUS (SRM7.0) and part of the requirement is that we need to update vendor bank details in our ECC6.0 backend once our vendors have updated it in our SUS portal. We have used BBPGETVD to transfer data from our ECC to

  • Adding Social Sharing Buttons To Android Application

    Hi; How can i adding a social sharing buttons (facebook, twitter etc.) to pages (views/mypage.xml, views/mypage1.xml) in my android apllication. Sincerely

  • Need a Mac Pro Box

    Hello, Can anyone tell me where I can find a new/refurbed Mac Pro desktop box? I am moving home soon and will thereafter be selling my Mac Pro. I have tried to find a suitable box to not only manage until I move, but to fit the desktop for selling an