/// <summary> /// Read river network or stream gage information and return a list of StateMod_RiverNetworkNode. </summary> /// <param name="filename"> Name of file to read. </param> /// <exception cref="Exception"> if there is an error reading the file. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_RiverNetworkNode> readStateModFile(String filename) throws Exception public static IList <StateMod_RiverNetworkNode> readStateModFile(string filename) { string rtn = "StateMod_RiverNetworkNode.readStateModFile"; IList <StateMod_RiverNetworkNode> theRivs = new List <StateMod_RiverNetworkNode>(); string iline, s; IList <object> v = new List <object>(7); int[] format_0; int[] format_0w; format_0 = new int[7]; format_0[0] = StringUtil.TYPE_STRING; format_0[1] = StringUtil.TYPE_STRING; format_0[2] = StringUtil.TYPE_STRING; format_0[3] = StringUtil.TYPE_STRING; format_0[4] = StringUtil.TYPE_STRING; format_0[5] = StringUtil.TYPE_STRING; format_0[6] = StringUtil.TYPE_STRING; format_0w = new int [7]; format_0w[0] = 12; format_0w[1] = 24; format_0w[2] = 12; format_0w[3] = 1; format_0w[4] = 12; format_0w[5] = 1; format_0w[6] = 8; int linecount = 0; if (Message.isDebugOn) { Message.printDebug(10, rtn, "in " + rtn + " reading file: " + filename); } StreamReader @in = null; try { @in = new StreamReader(filename); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { ++linecount; // check for comments if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } // allocate new StateMod_RiverNetworkNode StateMod_RiverNetworkNode aRiverNode = new StateMod_RiverNetworkNode(); // line 1 if (Message.isDebugOn) { Message.printDebug(50, rtn, "line 1: " + iline); } StringUtil.fixedRead(iline, format_0, format_0w, v); if (Message.isDebugOn) { Message.printDebug(50, rtn, "Fixed read returned " + v.Count + " elements"); } aRiverNode.setID(((string)v[0]).Trim()); aRiverNode.setName(((string)v[1]).Trim()); aRiverNode.setCstadn(((string)v[2]).Trim()); // 3 is whitespace // Expect that we also may have the comment and possibly the gwmaxr value... aRiverNode.setComment(((string)v[4]).Trim()); // 5 is whitespace s = ((string)v[6]).Trim(); if (s.Length > 0) { aRiverNode.setGwmaxr(StringUtil.atod(s)); } // add the node to the vector of river nodes theRivs.Add(aRiverNode); } } catch (Exception e) { Message.printWarning(3, rtn, "Error reading \"" + filename + "\" at line " + linecount); throw e; } finally { if (@in != null) { @in.Close(); } } return(theRivs); }